我刚开始使用 cxf,所以这可能是一个新手错误..
我正在阅读 soa 治理实践这本书,并下载了示例项目。
当我使用 cxf 从 wsdl 构建源代码时,它会将源代码放在 eclipse 的“目标”目录中。但这些是它创建的 java 文件,编译器似乎看不到它们,因此构建需要这些文件的应用程序会因编译器错误而失败。
我应该将“目标”中的生成源目录添加到构建路径还是什么?
非常感谢!
编辑:彻底困惑。这是pom
<build>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>
build-helper-maven-plugin
</artifactId>
<versionRange>[1.7,)</versionRange>
<goals>
<goal>add-source</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute></execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.cxf</groupId>
<artifactId>
cxf-codegen-plugin
</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>wsdl2java</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute></execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated/cxf</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>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/contract/accountService.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.manning.ossoagov.chapter2</groupId>
<artifactId>traffic-service-general</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
编辑:我也不清楚我应该如何构建它..?我将它作为 Eclipse 中的 Maven 构建运行,目标是生成源。这似乎产生了来源。但是我应该如何构建整个包?即使生成了源代码它也不会编译..?非常感谢!
编辑:更新的 Maven 日志
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.manning.ossoagov.chapter2:traffic-service-remoting-WS:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.cxf:cxf-rt-frontend-jaxws:jar -> duplicate declaration of version ${cxf.version} @ line 134, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Traffic Service WS Remoting 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- cxf-codegen-plugin:2.3.2:wsdl2java (generate-sources) @ traffic-service-remoting-WS ---
[INFO]
[INFO] --- build-helper-maven-plugin:1.7:add-source (add-source) @ traffic-service-remoting-WS ---
[INFO] Source directory: /Users/bw/Documents/workspace3/traffic-service-remoting-WS/target/generated/cxf added.
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ traffic-service-remoting-WS ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ traffic-service-remoting-WS ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ traffic-service-remoting-WS ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 1 resource
[INFO] [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ traffic-service-remoting-WS ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.7.1:test (default-test) @ traffic-service-remoting-WS ---
[INFO] Surefire report directory: /Users/bw/Documents/workspace3/traffic-service-remoting-WS/target/surefire-reports
T E S T S
-------------------------------------------------------
There are no tests to run.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ traffic-service-remoting-WS ---
[INFO] Building jar: /Users/bw/Documents/workspace3/traffic-service-remoting-WS/target/traffic-service-remoting-WS-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ traffic-service-remoting-WS ---
[INFO] Installing /Users/bw/Documents/workspace3/traffic-service-remoting-WS/target/traffic-service-remoting-WS-0.0.1-SNAPSHOT.jar to /Users/bw/.m2/repository/org/manning/ossoagov/chapter2/traffic-service-remoting-WS/0.0.1-SNAPSHOT/traffic-service-remoting-WS-0.0.1-SNAPSHOT.jar
[INFO] Installing /Users/bw/Documents/workspace3/traffic-service-remoting-WS/pom.xml to /Users/bw/.m2/repository/org/manning/ossoagov/chapter2/traffic-service-remoting-WS/0.0.1-SNAPSHOT/traffic-service-remoting-WS-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.179s
[INFO] Finished at: Tue Apr 16 07:49:17 BST 2013
[INFO] Final Memory: 11M/81M
[INFO] ------------------------------------------------------------------------
编辑:试图缩小范围。我有一个“Maven 问题”,“目标 org.apache.cxf:cxf-codegen-plugin:2.3.2:wsdl2java 的执行生成源失败。(org.apache.cxf:cxf-codegen-plugin:2.3.2 :wsdl2java:generate-sources:generate-sources)"
但是,如果我转到命令行并执行 mvn org.apache.cxf:cxf-codegen-plugin:wsdl2java
然后我得到建立成功
eclipse的自动构建是否有可能没有以相同的方式运行它?可能是警告..?
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.manning.ossoagov.chapter2:traffic-service-remoting-WS:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.cxf:cxf-rt-frontend-jaxws:jar -> duplicate declaration of version ${cxf.version} @ line 134, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Traffic Service WS Remoting 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- cxf-codegen-plugin:2.3.2:wsdl2java (default-cli) @ traffic-service-remoting-WS ---
[INFO] Nothing to generate
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.868s
[INFO] Finished at: Tue Apr 16 09:37:40 BST 2013
[INFO] Final Memory: 6M/81M
[INFO] ------------------------------------------------------------------------