spring-boot-maven-plugin打破了兄弟模块的依赖关系 [英] spring-boot-maven-plugin breaks sibling module dependency

查看:418
本文介绍了spring-boot-maven-plugin打破了兄弟模块的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多模块Maven设置.一个父模块,再加上两个子模块(子模块)A和B.模块B对A具有依赖关系.但是,如果我在模块A中使用spring-boot-maven-plugin,则编译依赖关系不会得到解决. ,并且模块B的编译目标将引发找不到符号"和包装不存在"错误.如果我不使用该插件,则一切正常,但是我将无法在此项目中将其删除.

I have a multi-module maven setup. A parent module, plus two sub-modules (children), A and B. Module B has a dependency on A. However, if I use the spring-boot-maven-plugin in module A, the compilation dependency doesn't get resolved, and the compile goal for module B will throw 'cannot find symbol' and 'package does not exist' errors. Everything works if I don't use that plugin, however I will not be able to remove it in this project.

这是重现问题的一种方法:

Here is a way to reproduce the problem:

父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 clean install'可以很好地进行编译.但是,一旦将此插件添加到模块A中:

Now, all you have to do is have a class in Module A, and another class in Module B, which imports and uses the first class. It should compile fine, when done so by running 'mvn clean install' at the parent module level. However, once this plugin is added in Module 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中看到该类.

, Module B can no longer resolve dependencies from Module A, and you will see 'package does not exist', 'cannot find symbol', etc. messages, indicating it can't see the class from Module A.

这是一个错误吗?谁能帮助我解决这个问题?

Is this a bug? Can anyone help me to get around this problem?

推荐答案

希望此帖子可能会对您有所帮助.

Hope this post might help you.

这篇关于spring-boot-maven-plugin打破了兄弟模块的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆