首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >spring-boot-maven-plugin打破了兄弟模块的依赖关系。

spring-boot-maven-plugin打破了兄弟模块的依赖关系。
EN

Stack Overflow用户
提问于 2017-04-11 23:52:34
回答 1查看 4.2K关注 0票数 4

我有一个多模块的maven设置。一个父模块,加上两个子模块(子模块),A和B模块B对A有依赖关系。但是,如果我在模块A中使用spring maven-plugin,编译依赖关系无法得到解决,模块B的编译目标将抛出“找不到符号”和“包不存在”错误。所有的工作,如果我不使用那个插件,但我将无法删除它在这个项目。

这里有一个重现问题的方法:

亲本pom.xml

代码语言:javascript
复制
<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

代码语言:javascript
复制
<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

代码语言:javascript
复制
<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中:

代码语言:javascript
复制
<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中的类。

这是个虫子吗?有人能帮我解决这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-12 00:30:37

希望这个帖子能帮到你。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43358016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档