像模块maven项目更改父级的Spring启动

时间:2017-11-14 06:52:12

标签: java maven spring-boot

我有项目

-MyProject
    main.pom
  - spring-boot
    spring-boot.pom
  - maven module
    module.pom
  - maven module2
    module2.pom

MyProject是拥有vwrsions属性的父级。 modulemodule2 chields并且有parnet - MyProject

例如在主要的pom中:

<properties>
    <spring.ws.version>3.0.0.RELEASE</spring.ws.version>
    ....
  </properties>

以及modulemodule2 pom:

<dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
            <version>${spring.ws.version}</version>
        </dependency>

由于:

<parent>
        <artifactId>main.project</artifactId>
        <groupId>a.project</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

但是在spring boot模块中已经是parent:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.M6</version>
        <relativePath/>
    </parent>

如何将父级更改为MyProject并使用spring boot?

1 个答案:

答案 0 :(得分:1)

您可以将Spring Boot父pom定义放在父pom的依赖关系管理部分中。

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

详细信息:https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-build-systems.html#using-boot-maven-without-a-parent