1.2. 使用 Spring Boot BOM 管理依赖项版本
使用产品 BOM 管理应用程序项目中的 Spring Boot 产品依赖项版本。
流程
将
dev.snowdrop:snowdrop-dependencies工件添加到项目的pom.xml的 <dependencyManagement> 部分,并指定 <type> 和 <scope>属性的值:<project> ... <dependencyManagement> <dependencies> <dependency> <groupId>dev.snowdrop</groupId> <artifactId>snowdrop-dependencies</artifactId> <version>2.5.12.Final-redhat-00001</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> ... </project>包含以下属性来跟踪您使用的 Spring Boot Maven 插件的版本:
<project> ... <properties> <spring-boot-maven-plugin.version>2.5.12</spring-boot-maven-plugin.version> </properties> ... </project>指定包含 BOM 和支持的 Spring Boot Starters 和 Spring Boot Maven 插件的存储库的名称和 URL:
<!-- Specify the repositories containing Spring Boot artifacts. --> <repositories> <repository> <id>redhat-ga</id> <name>Red Hat GA Repository</name> <url>https://maven.repository.redhat.com/ga/</url> </repository> </repositories> <!-- Specify the repositories containing the plugins used to execute the build of your application. --> <pluginRepositories> <pluginRepository> <id>redhat-ga</id> <name>Red Hat GA Repository</name> <url>https://maven.repository.redhat.com/ga/</url> </pluginRepository> </pluginRepositories>添加
spring-boot-maven-plugin作为 Maven 用于打包应用程序的插件。<project> ... <build> ... <plugins> ... <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring-boot-maven-plugin.version}</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> <configuration> <redeploy>true</redeploy> </configuration> </plugin> ... </plugins> ... </build> ... </project>