解析spring-boot-starter-parent簡介
本指南將幫助您了解Spring Boot Starter Parent如何幫助管理依賴項(xiàng)版本,所有Spring Boot項(xiàng)目通常使用spring-boot-starter-parent作為pom.xml中的父項(xiàng):
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
Parent Poms為多個(gè)子項(xiàng)目和模塊管理以下內(nèi)容:
- 配置 - Java版本和其他屬性
- Depedency Management - 依賴項(xiàng)的版本
- 默認(rèn)插件配置
內(nèi)部原理
首先 啟動(dòng)器Spring Boot Starter Parent將spring-boot-dependencies定義為父pom。它從spring-boot-dependencies繼承了依賴關(guān)系管理。
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.4.0.RELEASE</version> <relativePath>../../spring-boot-dependencies</relativePath> </parent>
默認(rèn)的java版本是1.6。項(xiàng)目可以通過<java.version>1.8</java.version>在項(xiàng)目pom中指定屬性來覆蓋它。還有一些與編碼和源相關(guān)的其他設(shè)置,目標(biāo)版本也在父pom中設(shè)置。
<java.version>1.6</java.version>
<resource.delimiter>@</resource.delimiter> <!-- delimiter that doesn't clash with Spring ${} placeholders -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
Spring Boot Starter Parent指定了一系列插件的默認(rèn)配置,包括maven-failsafe-plugin,maven-jar-plugin和maven-surefire-plugin。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>${start-class}</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Tests.java</include>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/Abstract*.java</exclude>
</excludes>
</configuration>
</plugin>
Spring Boot Starter Parent從spring-boot-dependencies繼承了什么?
Spring Boot Dependencies定義了所有Spring Boot項(xiàng)目的默認(rèn)依賴關(guān)系管理。如果我們想要使用特定依賴項(xiàng)的新版本,我們可以通過在項(xiàng)目pom中指定新屬性來覆蓋該版本。下面的摘錄顯示了由Spring Boot Dependencies父pom管理的一些重要依賴項(xiàng)。由于Spring Boot Starter Parent繼承自spring-boot-dependencies,因此它也共享所有這些特性。
<properties>
<activemq.version>5.13.4</activemq.version>
...
<ehcache.version>2.10.2.2.21</ehcache.version>
<ehcache3.version>3.1.1</ehcache3.version>
...
<h2.version>1.4.192</h2.version>
<hamcrest.version>1.3</hamcrest.version>
<hazelcast.version>3.6.4</hazelcast.version>
<hibernate.version>5.0.9.Final</hibernate.version>
<hibernate-validator.version>5.2.4.Final</hibernate-validator.version>
<hikaricp.version>2.4.7</hikaricp.version>
<hikaricp-java6.version>2.3.13</hikaricp-java6.version>
<hornetq.version>2.4.7.Final</hornetq.version>
<hsqldb.version>2.3.3</hsqldb.version>
<htmlunit.version>2.21</htmlunit.version>
<httpasyncclient.version>4.1.2</httpasyncclient.version>
<httpclient.version>4.5.2</httpclient.version>
<httpcore.version>4.4.5</httpcore.version>
<infinispan.version>8.2.2.Final</infinispan.version>
<jackson.version>2.8.1</jackson.version>
....
<jersey.version>2.23.1</jersey.version>
<jest.version>2.0.3</jest.version>
<jetty.version>9.3.11.v20160721</jetty.version>
<jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version>
<spring-security.version>4.1.1.RELEASE</spring-security.version>
<tomcat.version>8.5.4</tomcat.version>
<undertow.version>1.3.23.Final</undertow.version>
<velocity.version>1.7</velocity.version>
<velocity-tools.version>2.0</velocity-tools.version>
<webjars-hal-browser.version>9f96c74</webjars-hal-browser.version>
<webjars-locator.version>0.32</webjars-locator.version>
<wsdl4j.version>1.6.3</wsdl4j.version>
<xml-apis.version>1.4.01</xml-apis.version>
</properties>
將Maven 3.2.1定義為所需的最低版本:
<prerequisites> <maven>3.2.1</maven> </prerequisites>
總結(jié)
以上所述是小編給大家介紹的spring-boot-starter-parent簡介,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
spring中BeanUtils.copyProperties的使用(深拷貝,淺拷貝)
本文主要介紹了spring中BeanUtils.copyProperties的使用(深拷貝,淺拷貝),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05
Java實(shí)現(xiàn)二分查找BinarySearch算法
這篇文章主要介紹了Java實(shí)現(xiàn)二分查找BinarySearch算法,二分查找針對的是一個(gè)有序的數(shù)據(jù)集合,每次都通過跟區(qū)間的中間元素對比,將待查找的區(qū)間縮小為之前的一半,直到找到要查找的元素,或者區(qū)間被縮小為 0,需要的朋友可以參考下2023-12-12
使用MyBatis查詢千萬級數(shù)據(jù)量操作實(shí)現(xiàn)
這篇文章主要為大家介紹了如何使用MyBatis?查詢千萬數(shù)據(jù)量的操作過程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-05-05
springboot實(shí)現(xiàn)敏感字段加密存儲(chǔ)解密顯示功能
這篇文章主要介紹了springboot實(shí)現(xiàn)敏感字段加密存儲(chǔ),解密顯示,通過mybatis,自定義注解+AOP切面,Base64加解密方式實(shí)現(xiàn)功能,本文通過代碼實(shí)現(xiàn)給大家介紹的非常詳細(xì),需要的朋友可以參考下2022-02-02
spring-boot-maven-plugin報(bào)紅解決方案(親測有效)
本文主要介紹了spring-boot-maven-plugin報(bào)紅解決方案,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03

