当我尝试运行"mvn generate-sources"时,这是我的输出:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gensourcesfromwsdl 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.104s
[INFO] Finished at: Tue Aug 20 15:41:10 BST 2013
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我没有收到任何错误,但没有从wsdl文件生成的java类.
这是我正在运行插件的pom.xml文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gensourcesfromwsdl</groupId>
<artifactId>gensourcesfromwsdl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlLocation>http://mysite/firstwsdl.asmx?wsdl</wsdlLocation>
<packageName>com</packageName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么 ?该包com存在于项目'gensourcesfromwsdl'中,并且wsdl位置有效.
当我wsimport通过命令行运行时:> wsimport -keep -verbose http://mysite/firstwsdl.asmx?wsdl生成类.
小智 36
要从WSDL生成类,您需要的是pom.xml中的build-helper-maven-plugin和jaxws-maven-plugin
确保已将wsdl放在src/main/resources/wsdl文件夹下以及src/main中的相应模式下/ resources/schema,从Project根目录运行命令"mvn generate-sources".
C:/Project root directory > mvn generate-sources
Run Code Online (Sandbox Code Playgroud)
生成的java类可以位于文件夹下
target/generated/src/main/java/com/raps/code/generate/ws.
Run Code Online (Sandbox Code Playgroud)
pom.xml片段
<basedir>
C:/Project root directory
</basedir>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/target/generated/src/main/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<configuration>
<wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
<packageName>com.raps.code.generate.ws</packageName>
<keep>true</keep>
<sourceDestDir>${basedir}/target/generated/src/main/java</sourceDestDir>
</configuration>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
Cas*_*ian 26
下面是一个如何使用来自url或文件位置的jaxws maven插件从wsdl生成类的示例(来自wsdl文件位置的注释).
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<build>
<plugins>
<!-- usage of jax-ws maven plugin-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>wsimport-from-jdk</id>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- using wsdl from an url -->
<wsdlUrls>
<wsdlUrl>
http://myWSDLurl?wsdl
</wsdlUrl>
</wsdlUrls>
<!-- or using wsdls file directory -->
<!-- <wsdlDirectory>src/wsdl</wsdlDirectory> -->
<!-- which wsdl file -->
<!-- <wsdlFiles> -->
<!-- <wsdlFile>myWSDL.wsdl</wsdlFile> -->
<!--</wsdlFiles> -->
<!-- Keep generated files -->
<keep>true</keep>
<!-- Package name -->
<packageName>com.organization.name</packageName>
<!-- generated source files destination-->
<sourceDestDir>target/generatedclasses</sourceDestDir>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
小智 6
尽管这有点晚了,但可能对某人有帮助。看起来您已经使用了 pluginManagement。如果您使用 pluginManagement ,它不会选择插件执行。
它应该在
<build>
<plugins>
<plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
110177 次 |
| 最近记录: |