gpt4 book ai didi

java - cxf 将源文件放在目标中但编译器看不到它们?

转载 作者:搜寻专家 更新时间:2023-10-31 19:34:00 25 4
gpt4 key购买 nike

我刚开始使用 cxf,所以这可能是一个新手错误..

我正在阅读 soa governance in action 这本书,并下载了示例项目。

当我使用 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] ------------------------------------------------------------------------

最佳答案

你应该将这个文件夹添加到类路径中,使用 maven 你可以这样做:

      <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>add-wsdl-source</id>
<phase>process-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/path/to/generated/sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>

关于java - cxf 将源文件放在目标中但编译器看不到它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16029798/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com