Spring Boot學習-pom初探

Maven的用戶能夠經過繼承spring-boot-starter-parent項目來得到一些合理的默認配置:spring

默認使用Java 8
使用UTF-8編碼
一個引用管理的功能,在dependencies裏的部分配置能夠不用填寫version信息,這些version信息會從spring-boot-dependencies裏獲得繼承。
識別過來資源過濾(Sensible resource filtering.)
識別插件的配置(Sensible plugin configuration (exec plugin, surefire, Git commit ID, shade).)
可以識別application.properties和application.yml類型的文件,同時也能支持profile-specific類型的文件(如: application-foo.properties and application-foo.yml,這個功能能夠更好的配置不一樣生產環境下的配置文件)。
maven把默認的佔位符${…​}改成了@..@

若是dependencies中的一些引用不想使用默認的版本,能夠直接加上version信息<properties>把默認的覆蓋掉。app

注意:parent的pom中依然默認有<parent>標籤:spring-boot-dependencies;maven

若是不想使用spring-boot-starter-parent,也能夠本身來配置所要使用的版本,可是,這種方式下若是想要某些引用的版本特殊說明,就要在上面的聲明以前配置(spring-boot-dependencies以前,同時<scope>import</scope>是關鍵):ide

<dependencyManagement>
    <dependencies>
        <!-- Override Spring Data release train provided by Spring Boot -->
        <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>2.0.0.BUILD-SNAPSHOT</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
相關文章
相關標籤/搜索