Spring IO Platform学习总结

1:Spring IO Platform

Spring IO Plat是一个附带包,不会编译到项目中,它只是将核心Spring API框架内聚集成到一个现代应用程序的平台中。它提供了已经测试完毕能很好协同工作的许多项目的Spring组合版本以及它们的依赖项。你在引入新的Spring IO Platform时不用带版本号的

2:Maven使用Spring IO Platform

  1. 使用pom的形式引入Spring IO Platform
  2. Spring IO Platform官网:https://docs.spring.io/platform/docs/
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.spring.platform</groupId>
                <artifactId>platform-bom</artifactId>
                <version>1.1.2.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
       <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!--pom形式引入,需要加入configuration的executable--!>
                <configuration>
                    <executable>true</executable>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
  1. 使用父依赖的方式引入Spring IO Platform
     <parent>
        <!--
            io.spring.platform bom Brussels-SR7
            springframework version 4.3.13.RELEASE
            spring boot version 1.5.9.RELEASE
        -->
        <groupId>io.spring.platform</groupId>
        <artifactId>platform-bom</artifactId>
        <version>Brussels-SR6</version>
        <relativePath/>
    </parent>
         <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!--parent形式引入,不需要加入configuration的executable--!>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

3:覆盖Spring IO Platform的依赖版本号

<properties>
  <foo.version>1.2.0.RELEASE</foo.version>
</properties>

在使用Spring IO Platform项目的依赖管理时,应根据项目的实际运行环境来合理选择版本号,除非必须,否则不建议修改版本信息。在修改依赖包的版本信息时,可通过IDE点击坐标来查看依赖包对应的属性名。

4:Spring Boot dependency和 Spring Framework

            <!--
                spring boot pom
                spring boot version 1.5.2.RELEASE
                spring boot 项目的集成
            -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!--
                spring framework bom
                spring framework version 4.3.7.RELEASE
                spring framework 集成
            -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-framework-bom</artifactId>
                <version>${spring-framework-bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

5:总结

Spring IO Platform项目的本质就是一个pom文件,它记录了Spring项目和其它第三方库对应的版本信息。由于Spring IO Platform项目帮助我们做了大量的集成和测试工作,使得我们可以轻松使用

猜你喜欢

转载自blog.csdn.net/A169388842/article/details/82799765