我有一个多模块的maven设置。一个父模块,加上两个子模块(子模块),A和B模块B对A有依赖关系。但是,如果我在模块A中使用spring maven-plugin,编译依赖关系无法得到解决,模块B的编译目标将抛出“找不到符号”和“包不存在”错误。所有的工作,如果我不使用那个插件,但我将无法删除它在这个项目。
这里有一个重现问题的方法:
亲本pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>com.whatever</groupId>
<artifactId>theparent</artifactId>
<version>2.7.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>service</module>
<module>serviceClient</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>单元A
<modelVersion>4.0.0</modelVersion>
<artifactId>service</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>com.whatever</groupId>
<artifactId>theparent</artifactId>
<version>2.7.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>单元B
<modelVersion>4.0.0</modelVersion>
<artifactId>serviceClient</artifactId>
<parent>
<groupId>com.whatever</groupId>
<artifactId>theparent</artifactId>
<version>2.7.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>com.whatever</groupId>
<artifactId>service</artifactId>
<version>2.7.0-SNAPSHOT</version>
</dependency>
</dependencies>现在,您所要做的就是在模块A中有一个类,在模块B中有另一个类,它导入和使用第一个类。如果通过在父模块级别运行'mvn干净安装‘来编译的话,它应该会编译得很好。但是,一旦将这个插件添加到模块A中:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.whatever.Application</mainClass>
</configuration>
</plugin>
</plugins>
</build>,模块B不能再解析模块A中的依赖项,您将看到“包不存在”、“找不到符号”等消息,表明它看不到模块A中的类。
这是个虫子吗?有人能帮我解决这个问题吗?
发布于 2017-04-12 00:30:37
希望这个帖子能帮到你。
https://stackoverflow.com/questions/43358016
复制相似问题