方式一:繼承 spring-boot-starter-parent項目spring
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> </parent>
方式二:導入spring-boot-dependencies項目依賴spring-boot
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.5.12.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
由於通常咱們的項目中,都有項目本身的parent項目。因此【方式一】會存在衝突,實際場景下,推薦使用【方式二】。 須要注意的是,在子項目的dependencies中,不須要(也不能)再次添加對spring-boot-dependencies的聲明瞭,不然子項目將沒法編譯經過。.net
爲何呢?由於spring-boot-dependencies沒有對應的jar包,它只是一個pom配置,裏面定義了不少的依賴聲明。有了它以後,咱們在子項目中使用到的相關依賴,就不須要聲明version了。code