几个小时前我刚刚遇到了这个问题,直到现在它似乎一直有效。
我通过以下方式在我的 pom 中生成代码:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<configuration>
<sourceDestDir>${basedir}/target/generated/java</sourceDestDir>
<keep>true</keep>
<verbose>true</verbose>
<extension>true</extension>
<wsdlDirectory>${basedir}/src/main/resources/META-INF</wsdlDirectory>
</configuration>
<executions>
<execution>
<id>ecad-ws</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>wsdl/ECadDocumentServiceWSDL.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>${project.build.directory}/jaxws/stale/wsdl.ECadDocumentServiceWSDL.done</staleFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${basedir}/src/main/resources/META-INF/xsd</schemaDirectory>
<packageName>be.fgov.health.ecad.xmlstructure</packageName>
<outputDirectory>${basedir}/target/generated/java</outputDirectory>
</configuration>
</plugin>
我在我的项目中使用这些生成的类。 如果我然后执行“右键单击 -> maven -> clean”+“右键单击 -> maven -> install”,则一切正常。 但是当我运行 mvn clean install -DskipTest=true 时,maven 找不到生成的源..我已经被困了几个小时并且无法真正找到它。 (顺便说一句,在 Eclipse 中执行此操作)
编辑:
刚刚弄清楚以下内容:如果我删除第二个插件(由 xsd 生成),我不会收到任何错误。如果我将所有使用生成的类的代码放在注释 ofc 中。
另一个编辑:
我已经更改了 jaxb 生成的 outputDirectory,现在它可以工作了。谁能解释一下为什么它不能与 wsimport 位置相同?
最佳答案
默认情况下,jaxb2-maven-plugin
在将生成的类放入其中之前会删除 outputDirectory
。
您可以使用属性 clearOutputDir
控制此行为。您的插件配置将如下所示:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${basedir}/src/main/resources/META-INF/xsd</schemaDirectory>
<packageName>be.fgov.health.ecad.xmlstructure</packageName>
<outputDirectory>${basedir}/target/generated/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
关于java - maven 找不到生成的源(mvn clean install),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28814080/