Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Use Spring IO and Spring Boot Together

DZone's Guide to

How to Use Spring IO and Spring Boot Together

Learn about using Spring IO and Spring Boot together, with an overview of the Spring IO platform and look at Spring Boot, and the two working together.

· Integration Zone
Free Resource

The Integration Zone is brought to you in partnership with Cloud Elements.  What’s below the surface of an API integration? Download The Definitive Guide to API Integrations to start building an API strategy.

Hi everyone! I’m going to introduce really quick Spring Boot and Spring IO Platform and how to use them together.

Spring IO Platform

Spring IO Platform defines a set of dependencies (both Spring Framework dependencies as third-party libraries) that could be included in a Java project to allow you to choose the necessary dependencies without worrying about compatibility between their versions (because Spring IO guarantees it).

The recommended way to get started using the platform in your project is with a dependency management system.

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

After including the Spring IO Platform dependency in your project with pom value as type and import value as scope, you will be able to include all necessary dependencies without specifying its version.

On the next sample, you could see how to include the Hibernate dependency without specifying the version.

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
</dependency>

To know all libraries and their versions included on Spring IO Platform, you should read Appendix - Dependency Versions.

Spring Boot

Spring Boot is a framework that makes development and configuration of Spring applications easy. This could be possible thanks to a list of predefined properties and configuration classes that could be included using Java annotations and starters.

The recommended way to get started using spring-boot in your project is with a dependency management system.

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.1.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
</dependencies>

You could get more info about Spring Boot project and how to work with it reading Spring Boot reference guide.

Spring IO and Spring Boot Together

Now that you know that Spring Boot makes the Spring configuration easy using starters as dependencies and that you know that Spring IO Platform allows you to manage your project dependencies without worrying about versions, I’m going to explain to you how to use them together to get the most of them.

As we read, Spring Boot recommends specifying spring-boot-starter-parent dependency as a parent. However, reading the list of dependencies included by Spring IO Platform you could see that it includes all necessary Spring Boot libraries and Spring Boot starters. In addition, if we check the Spring IO Platform pom.xml file, we can see that Spring IO Platform project has Spring Boot as a parent. That’s the reason because Spring IO Platform includes all Spring Boot dependencies.

So the recommended way to use Spring IO Platform and Spring Boot in the same project is to use Spring IO Platform as parent like the following sample:

<parent>
    <groupId>io.spring.platform</groupId>
    <artifactId>platform-bom</artifactId>
    <version>2.0.0.RELEASE</version>
    <relativePath/>
</parent>

And then, include the Spring Boot starters and dependencies without worrying about the version like the following sample:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
</dependency>

Conclusions

  • Spring IO Platforms allows you to manage dependencies without worrying about the versions and compatibility between them.
  • Spring Boot makes the Spring application configuration easy using predefined properties, annotations and starters as dependencies.
  • Spring IO Platform includes Spring Boot as a parent. That’s the reason because Spring IO Platform includes all Spring Boot dependencies and starters.
  • Use Spring IO Platform as a parent if you want to use Spring IO Platform and Spring Boot together.

Hope you enjoy with this post and you learn more about Spring technologies.

If you have some comment or question, feel free to make it, you’ll also find @disid_corp on Twitter.

See you soon!

Original Author: Juan Carlos García, Software Architect at DISID

The State of API Integration Report provides data from the Cloud Elements platform and will help all developers navigate the recent explosion of APIs and the implications of API integrations to work more efficiently in 2017 and beyond.

Topics:
spring boot ,spring io ,spring

Published at DZone with permission of Pilar Argudo. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}