在以下项目结构中:
Parent
- ProjectA
- ProjectB
- etc.
当我从 ProjectA
中运行 mvn clean install
时,ProjectA
正确构建。
但是,当我从 Parent
文件夹运行 mvn clean install
时,出现以下错误:
[ERROR] Failed to execute goal org.apache.axis2:axis2-wsdl2code-maven-plugin:1.5.6:wsdl2code
(default) on project ProjectA: Error parsing WSDL:
WSDLException: faultCode=OTHER_ERROR: Unable to resolve imported document
at 'target/TcWebService.wsdl'.: java.io.FileNotFoundException:
This file was not found:
file:/D:{PATH_TO_PARENT}/target/TcWebService.wsdl -> [Help 1]
正确的路径为file:/D:{PATH_TO_PARENT}/ProjectA/target/TcWebService.wsdl
。 ProjectA
部分缺失
父.pom
<modules>
<module>ProjectA</module>
<module>ProjectB</module>
...
</modules>
项目A pom:
<parent>
<groupId>{MY.GROUP.ID}</groupId>
<artifactId>jars</artifactId>
<version>1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
...
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<configuration>
<tasks>
<copy file="src/main/wsdl/TcWebService.wsdl"
tofile="target/TcWebService.wsdl"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
请问有什么想法吗?
最佳答案
您可以采用更 Maven 的方法来解决这个问题,这样 Maven 就可以更轻松地完成您的要求。
maven-resources-plugin
肯定会对您有所帮助。
在这里阅读:https://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html
编辑
我认为这里的问题是工作目录。当您运行子模块时,您位于子项目的目录中。所以 childProject\target
适合你。但是,当您运行主项目时,您位于父目录中,这不起作用。因此,需要通过在复制任务的 file
和 tofile
中提供文件的绝对路径来解决此问题。 ${project.basedir}
作为路径的前缀可能会有所帮助。
关于java - Maven父pom : Unable to resolve imported document,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42999167/