Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading Spring Boot Application to Latest Version

I have a Spring Boot project which is based on
Spring Framework 4.3.7.RELEASE and Spring Boot 1.5.2.RELEASE.
I use the Java configuration approach. How Do I upgrade this project to the latest version of Spring Boot and Spring Framework (Spring Boot 2.x, Spring Framework 5.x)? I have checked out this page, but unfortunately it was of no real help to me. Would be glad to receive any further guidance on this.

This is how my build.gradle file looks like:

buildscript {
    ext {
        springBootVersion = '1.5.2.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

version = '0.1.0-alpha.2'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

bootRun.systemProperties = System.properties

springBoot {
    executable = true
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-security')
    compile('mysql:mysql-connector-java')
    compile('org.modelmapper:modelmapper:1.1.0')
    compile('com.fasterxml.jackson.datatype:jackson-datatype-jsr310')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile('org.springframework.security:spring-security-test')
    testCompile('org.modelmapper:modelmapper:1.1.0')
}
like image 621
André Gasser Avatar asked Nov 24 '17 11:11

André Gasser


People also ask

How do I upgrade my Spring Boot project?

To upgrade an existing CLI installation, use the appropriate package manager command (for example, brew upgrade ). If you manually installed the CLI, follow the standard instructions, remembering to update your PATH environment variable to remove any older references.

Which is the latest version of Spring Boot?

What is the latest Spring Boot version? The current stable version, as of July 2022, is Spring Boot 2.7. 1.

Can we convert spring application to Spring Boot?

Migrate a Spring Data Application If we want to work with a different database type and configuration, such as a MySQL database, then we need the dependency as well as to define a configuration. Spring Boot will auto-configure Hibernate as the default JPA provider, as well as a transactionManager bean.


1 Answers

The first step to do an upgrade, is to just increase the version of the spring-boot-starter-parent. In your case with Gradle, it would the version in the property springBootVersion.

For Spring Boot 2 however it is important to note, that there is no final release yet, so you have to include the milestone or snapshot repositories from Spring Boot. You can find the URLs here: https://docs.spring.io/spring-boot/docs/2.0.0.M4/reference/htmlsingle/#getting-started-first-application-pom though that documentation is for Maven.

The proper settings for Gradle would look like this:

buildscript {
    ext {
        springBootVersion = '2.0.0.M6'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}
like image 200
dunni Avatar answered Oct 24 '22 11:10

dunni