使用Apache CXF和CXF Maven插件在Eclipse Workspace中自动生成WSDL Java Stub [英] Automatic WSDL Java Stub generation in Eclipse Workspace using Apache CXF and CXF Maven Plugin
问题描述
我有一个Web服务生产者应用程序,具有WSDL和我希望应用程序中的存根从WSDL动态生成。
我已经安装了Maven Lifecycle Dependency并安装了两个M2E WTP连接器。在Eclipse Project - >属性 - > Maven - >生命周期映射中,我看到了cxf-codegen-plugin:wsdl2java,它显示它已经被正确附加到generate-sources生命周期阶段。
当我运行 mvn但是,如果我清理maven项目并将其加载到eclipse中,那么eclipse就会这样做不自动生成存根。我看到在Eclipse工作空间中缺少Java缺少的类错误,显示gen没有发生。
我错过了什么步骤?
这是我正在使用的POM。
<?xml version =1.0encoding =UTF-8?>
< 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> com.test< / groupId>
< artifactId> testWeb< / artifactId>
< version> 0.0.1-SNAPSHOT< / version>
< packaging> war< / packaging>
< name> testWeb< / name>
< properties>
< cxf.version> 2.1.3< / cxf.version>
< maven.compiler.source> 1.6< /maven.compiler.source>
< maven.compiler.target> 1.6< /maven.compiler.target>
< spring.version> 3.2.2.RELEASE< /spring.version>
< / properties>
< repositories>
< repository>
< id>快照< / id>
< name> ILP Snapshot Repository< / name>
< url> http://dhud001.test.com:8675 / maven_snapshot /< / url>
< releases>
< enabled> false< / enabled>
< / releases>
< snapshots>
< enabled> true< / enabled>
< updatePolicy> always< / updatePolicy>新新旗新新新旗新新旗旗新新旗200新新旗200新新新200新新旗200新新新新旗新新200新新旗新新旗旗
< / repository>
< repository>
< id> eclipse< / id>
< name> Eclipse< / name>
< url> https://repo.eclipse.org/content/repositories/releases/< / url>
< releases>
< enabled> true< / enabled>
< updatePolicy> daily< / updatePolicy>
< / releases>
< snapshots>
< enabled> false< / enabled>
< / snapshots>
< / repository>
< / repositories>
< pluginRepositories>
< pluginRepository>
< id> central< / id>
< name> Maven Plugin Repository< / name>
< url> http://repo1.maven.org/maven2< / url>
< layout> default< / layout>
< snapshots>
< enabled> false< / enabled>
< / snapshots>
< / pluginRepository>
< / pluginRepositories>
<依赖关系>
<依赖关系>
< groupId> org.apache.cxf< / groupId>
< artifactId> cxf< / artifactId>
< version> $ {cxf.version}< / version>
< / dependency>
< / dependencies>
< build>
< plugins>
< plugin>
< groupId> org.codehaus.mojo< / groupId>
< artifactId> build-helper-maven-plugin< / artifactId>
<执行>
< execution>
< phase> generate-sources< / phase>
< goals>
< goal> add-source< / goal>
< / goals>
< configuration>
< sources>
< source> src / gen / java< / source>
< / sources>
< / configuration>
< / execution>
< / executions>
< / plugin>
< plugin>
< groupId> org.apache.cxf< / groupId>
< artifactId> cxf-codegen-plugin< / artifactId>
< version> $ {cxf.version}< / version>
<执行>
< execution>
< id>生成源< / id>
< phase> generate-sources< / phase>
< configuration>
< useCompileClasspath> true< / useCompileClasspath> <! - 如果您不使用此功能,则soapui测试包将导致此插件的类加载问题。 - >
< sourceRoot> $ {project.basedir} / src / gen / java< / sourceRoot> X-45454545 X-4545 X-4545 X-4545 X- 200 X- 20045 X- 20045 X-新新旗200新新200新新旗200新新旗200新新新新旗200新新旗200新新新200新新新新名:
< wsdl> $ {project.basedir} /src/main/webapp/wsdl/TestService.wsdl</wsdl>
< wsdlLocation> classpath:wsdl / TestService.wsdl< / wsdlLocation>
< extraargs>
< extraarg> -verbose< / extraarg>
< extraarg> -all< / extraarg>新新旗200新新旗200新新新新旗200新新旗200新新旗200新新新新旗200
< / wsdlOption>
< / wsdlOptions>
< / configuration>
< goals>
< goal> wsdl2java< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< / plugins>
< / build>
< / project>
我能够安装Build helper maven连接器,并尝试安装 可以重现问题的示例eclipse项目在这里: https://www.dropbox.com/s/vlo0ghbmkplu7au/service.zip?dl=0 为了获得更新Maven项目以触发从Eclipse重建的cxf存根,您需要打开 由于某些原因手动清理目标文件夹内容会触发maven的cxf构建以生成存根。更改WSDL /删除生成的源src文件夹的内容不帮助。 I am using Apache CXF 2.x, Eclipse Luna 64-bit, Maven 3.x I have a single web service producer app that has a WSDL and I want the Stubs in the app to generate dynamically from the WSDL. I have installed the Maven Lifecycle Dependency and installed both M2E WTP connectors. In Eclipse Project -> Properties -> Maven -> Lifecycle Mapping, I see cxf-codegen-plugin:wsdl2java and it shows that it is properly attached to the generate-sources lifecycle phase. When I run But if I clean the maven project and load it in eclipse, eclipse does not automatically generate the stubs. I see Java missing class errors in Eclipse workspace showing the gen is not occurring. What step am I missing? Here is the POM that I am using. I was able to install Build helper maven connector and also tried to install https://code.google.com/a/eclipselabs.org/p/m2e-cxf-codegen-connector/ as well. But the sources continue to not generate. Example eclipse project that can reproduce the problem is here: https://www.dropbox.com/s/vlo0ghbmkplu7au/service.zip?dl=0 In order to get the "Update Maven Projects" to trigger the cxf stubs to be rebuilt from Eclipse you need to open the For some reason manually cleaning the target folder contents triggers maven's cxf build to generate the stubs. Changing the WSDL/deleting the contents of your generated sources src folder do not help. 这篇关于使用Apache CXF和CXF Maven插件在Eclipse Workspace中自动生成WSDL Java Stub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
目标
文件夹并删除 target / *
。然后点击 alt + f5 + enter
,您的存根将刷新。
mvn install
manually, the stubs are generated automatically and everything works fine.<?xml version="1.0" encoding="UTF-8"?>
<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>com.test</groupId>
<artifactId>testWeb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>testWeb</name>
<properties>
<cxf.version>2.1.3</cxf.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<spring.version>3.2.2.RELEASE</spring.version>
</properties>
<repositories>
<repository>
<id>snapshots</id>
<name>ILP Snapshot Repository</name>
<url>http://dhud001.test.com:8675/maven_snapshot/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>eclipse</id>
<name>Eclipse</name>
<url>https://repo.eclipse.org/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf</artifactId>
<version>${cxf.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/gen/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<useCompileClasspath>true</useCompileClasspath> <!-- if you don't use this, the soapui test bundle will cause classloading issues with this plugin. -->
<sourceRoot>${project.basedir}/src/gen/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${project.basedir}/src/main/webapp/wsdl/TestService.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/TestService.wsdl</wsdlLocation>
<extraargs>
<extraarg>-verbose</extraarg>
<extraarg>-all</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
target
folder and delete target/*
. Then hit alt + f5 + enter
and your stubs will refresh.