spring

Spring IO Platform

In this article, we’re going to discuss Spring IO Platform, a version management tool used in the Spring Framework environment. Also, we’ll see how to use it together with Spring Boot.

1. Introduction

Spring IO Platform brings together the core Spring APIs into a cohesive platform for modern applications. Also, It provides curated versions of numerous projects in the Spring environment.

When using it, we don’t need to concern about version and compatibility between them.

This platform was firstly intended to work with a dependency management system, like Maven or Gradle. However, it can use both to bring the necessary project’s dependencies.

In the next step, we’re going to see how the Spring IO Platform works and using it together with Spring Boot.

spring io

1.1 Pre-requisites

The minimum Java version for executing the article’s example is JDK 8 (find here), but we can use the most recently released Java version JDK 16 on Oracle’s official site or the OpenJDK version.

Also, I’m using the most recent IntelliJ version, but you can use any IDE with support for the versions recommended above.

2. How Spring IO Platform works

As we’ve seen earlier, it defines a set of dependencies that we can use in a Java project, regarding the worry about compatibility between the versions.

The focus primarily is to use the dependency manager (Maven or Gradle) to bring dependencies that are certainly working well together.

2.1 Using with Maven

To use Maven with Spring IO Platform, we just need to do some changes to the pom.xml file. The first way is importing the Platform’s bom into the pom’s dependency management:

Importing bom

<?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.javacodegeeks</groupId>
    <artifactId>springioplatform</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springioplatform</name>
    <description>Example of Spring IO Platform</description>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.spring.platform</groupId>
                <artifactId>platform-bom</artifactId>
                <version>Cairo-SR7</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <!-- Dependency declarations -->

</project>

Alternatively, we can use Platform as the pom’s parent:

Using as parent

<?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.javacodegeeks</groupId>
    <artifactId>springioplatform</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springioplatform</name>
    <description>Example of Spring IO Platform</description>

    <parent>
        <groupId>io.spring.platform</groupId>
        <artifactId>platform-bom</artifactId>
        <version>Cairo-SR7</version>
        <relativePath/>
    </parent>

    <!-- Dependency declarations -->

</project>

3. How to use Spring IO Platform and Spring Boot?

To use it together with Spring Boot we just put the Platform as the parent on pom file.

Platform as parent on Spring Boot pom

<?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.javacodegeeks</groupId>
    <artifactId>springioplatform</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springioplatform</name>
    <description>Example of Spring IO Platform</description>

    <parent>
        <groupId>io.spring.platform</groupId>
        <artifactId>platform-bom</artifactId>
        <version>Cairo-SR7</version>
        <relativePath/>
    </parent>

And then we insert the Spring Boot dependency.

Spring Boot dependency

<dependency>
    <groupId%gtorg.springframework.boot%lt/groupId>
    <artifactId%gtspring-boot-starter%lt/artifactId>
</dependency>

Spring IO Platform includes all Spring Boot starter dependencies. That said, this is the easiest way to make both tools working together.

Now, we don’t worry about project dependencies as Spring IO Platform will deal with this for us.

4. End of life

Sadly, Spring IO Platform reached the end of its supported life on 9 April 2019. The users are encouraged to use Spring Boot’s dependency management, using Maven spring-boot-start-parent as pom file parent, or importing the spring-boot-dependencies bom.

5. Summary

In summary, we saw the use of Spring IO Platform. As a dependency manager, the Platform offers an accurate version of dependencies, avoiding this concern for users.

Also, we saw how to it works together with Spring Boot in a pom file example.

This article was based on Spring Platform official document and can be consulted here.

6. Download the source code

Download
You can download the full source code of this example here: Spring IO Platform

Sergio Lauriano Junior

Sergio is graduated in Software Development in the University City of São Paulo (UNICID). During his career, he get involved in a large number of projects such as telecommunications, billing, data processing, health and financial services. Currently, he works in financial area using mainly Java and IBM technologies.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button