SpringBoot不作為parent POM引入---自己或公司的專案已有parent POM
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-maven-without-a-parent
13.2.2 Using Spring Boot without the parent POM
Not everyone likes inheriting from the spring-boot-starter-parent
POM.
You may have your own corporate standard parent that you need to use, or you may just prefer to explicitly declare all your Maven configuration.
If you don’t want to use the spring-boot-starter-parent
,
you can still keep the benefit of the dependency management (but not the plugin management) by using a scope=import
dependency:
<dependencyManagement> <dependencies> <dependency> <!-- Import dependency management from Spring Boot --><groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.5.9.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency></dependencies> </dependencyManagement>
That setup does not allow you to override individual dependencies using a property as explained above. To achieve the same result, you’d need to add an entry in thedependencyManagement
of
your project before the spring-boot-dependencies
entry.
For instance, to upgrade to another Spring Data release train you’d add the following to your pom.xml
.
<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>1.5.9.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
In the example above, we specify a BOM but any dependency type can be overridden that way. |