与bom的传递依赖

时间:2017-02-03 15:36:00

标签: maven spring-boot maven-bom

我有一个名为P1的项目,它是一个spring-boot项目。 pom已经有了一个父pom,所以我决定使用带有bom的springboot。

    <dependencyManagement>
        <dependencies>
            <dependency>
                <!-- Import dependency management from Spring Boot -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

然后将此项目部署为P1.jar

然后我有一个名为P2的第二个项目。 这个项目只有1个依赖,这是P1项目:

<dependencies>
    <dependency>
        <groupId>my.company</groupId>
        <artifactId>p1</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>

以下是项目的mvn依赖关系:树的摘录:

P1:

[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.3.RELEASE:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-jdbc:jar:8.5.6:compile
[INFO] |  |  |  \- org.apache.tomcat:tomcat-juli:jar:8.5.6:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:4.3.5.RELEASE:compile
[INFO] |  +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:1.10.6.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-orm:jar:4.3.5.RELEASE:compile

P2:

[INFO]    +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.3.RELEASE:compile
[INFO]    |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.3.RELEASE:compile
[INFO]    |  |  +- org.apache.tomcat:tomcat-jdbc:jar:8.5.6:compile
[INFO]    |  |  |  \- org.apache.tomcat:tomcat-juli:jar:8.5.6:compile
[INFO]    |  |  \- org.springframework:spring-jdbc:jar:4.3.5.RELEASE:compile
[INFO]    |  +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO]    |  +- org.springframework.data:spring-data-jpa:jar:1.10.6.RELEASE:compile
[INFO]    |  |  \- org.springframework:spring-orm:jar:4.2.9.RELEASE:compile

正如您所看到的,Spring-orm依赖性不同。 有人能解释我这是如何工作的,我该如何解决?

目前我在第二个项目中添加了BOM。但这不是我的目标。 我希望能够导入P1项目及其REAL依赖项,而无需做任何其他事情或知道项目正在使用哪个项目。

0 个答案:

没有答案