【发布时间】:2015-11-13 19:01:58
【问题描述】:
我正在使用 Apache CXF 2.x、Eclipse Luna 64 位、Maven 3.x
我有一个具有 WSDL 的 Web 服务生产者应用程序,我希望应用程序中的存根从 WSDL 动态生成。
我已经安装了 Maven Lifecycle Dependency 并安装了两个 M2E WTP 连接器。在 Eclipse Project -> Properties -> Maven -> Lifecycle Mapping 中,我看到 cxf-codegen-plugin:wsdl2java 并且它表明它已正确附加到 generate-sources 生命周期阶段。
当我手动运行mvn install 时,存根会自动生成,一切正常。
但是如果我清理 maven 项目并将其加载到 eclipse 中,eclipse 不会自动生成存根。我在 Eclipse 工作区中看到 Java 缺少类错误,显示 gen 没有发生。
我错过了什么步骤?
这是我正在使用的 POM。
<?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>
我能够安装 Build helper maven 连接器,并且还尝试安装 https://code.google.com/a/eclipselabs.org/p/m2e-cxf-codegen-connector/。但源继续不生成。
可以重现问题的示例eclipse项目在这里:https://www.dropbox.com/s/vlo0ghbmkplu7au/service.zip?dl=0
【问题讨论】:
-
您在 cxf-users 邮件列表中询问了吗?
-
我会调查一下,注册和东西很棘手。
-
您可能需要设置一些未记录的标志,例如
-Dm2e.cxf.actually.work.this.time=true或其他东西。 -
谢谢你提醒我为什么改用 IntelliJ,够用的 JAX-WS RI codegen,不够用的 Axis2,只做依赖和实际的 compile/jar/war/ejb/ear使用 Maven 的东西。
-
这绝对不是什么标志。我认为这是因为新版本的 jar 与它的旧工作方式相冲突。也许 MyEclipse 正确地解决了这个问题?