Spring IO Platform 解决Spring项目组合中版本依赖

参考

Spring IO Platform ,解决Spring项目组合中版本依赖
https://www.cnblogs.com/zhouqinxiong/p/spring_io_platform.html
https://www.jianshu.com/p/dd0baba45f52

简介

Spring IO Platform框架简单来说就是一个版本号兼容系统,它将常用第三方类库的兼容的版本组织起来。只要我们在项目中引用了Spring IO Platform,就不需要为这些第三方类库设置版本号了,Spring IO Platform会自动帮我们设置所有兼容的版本号。本文参考自官方文档,如果需要查阅详细信息,请直接看原文即可。

在这里插入图片描述

引入类库

使用Maven 方式一

使用Maven的话,在pom.xml中修改为类似这样的。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>your-application</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <!-- 添加以下一段-->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.spring.platform</groupId>
                <artifactId>platform-bom</artifactId>
                <version>Brussels-SR3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <!-- Dependency declarations -->

</project>

使用Maven 方式二

或者将设置Spring IO Platform为父项目也行。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>your-application</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <parent>
        <groupId>io.spring.platform</groupId>
        <artifactId>platform-bom</artifactId>
        <version>Brussels-SR3</version>
        <relativePath/>
    </parent>

    <!-- Dependency declarations -->

</project>

设置完成后,以后添加依赖项就不需要指定版本好了。可以像下面这样添加依赖。

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <!-- 没有版本号 -->
    </dependency>
</dependencies>

使用Gradle 方式一

おすすめ

転載: blog.csdn.net/wei198621/article/details/120927474
おすすめ