SpringBoot--解決不依賴父POM的問題

BtWangZhi發表於2017-11-20

參考:SpringBoot-1.5.8-RELEASE 25頁。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <!-- <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> 
        <version>1.5.8.RELEASE</version> </parent> -->
    <groupId>text</groupId>
    <artifactId>SpringBoot01</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-releasetrain</artifactId>
                <version>Fowler-SR2</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <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>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
</project>

通過在dependencyManagement中引入的一個父pom.xml中的依賴,重點在import這一項的配置,在dependencyManagement外側正常引用父POM已在dependencyManagement中定義的依賴的版本,在就可以實現多繼承父POM的問題,並且就可可以正常設定父專案了。
文件中有這樣一句話:
參考:http://blog.csdn.net/mn960mn/article/details/50894022

相關文章