How to Migrate Your Application to Spring Boot 2.0: Essential Steps and Tips
This guide walks you through upgrading a Java application to Spring Boot 2.0, covering prerequisites, adding the properties‑migrator module, Maven and Gradle build changes, key configuration updates, actuator and security adjustments, and other important migration details.
Prerequisites
Spring Boot 2.0 requires Java 8 or higher. Many configuration properties have been renamed or removed, so application.properties or application.yml files must be updated.
Properties Migrator
Add the spring-boot-properties-migrator module to your project to analyze the environment and print diagnostic information at startup. After migration, remove this dependency.
<ol>
<li><code><dependency></code></li>
<li><code><groupId>org.springframework.boot</groupId></code></li>
<li><code><artifactId>spring-boot-properties-migrator</artifactId></code></li>
<li><code></dependency></code></li>
</ol>Building Your Spring Boot Application
Maven Plugin
All exposed plugin configuration properties now start with the spring-boot prefix. Example to run with a profile:
mvn spring-boot:run -Dspring-boot.run.profiles=prodGradle Plugin
The Spring Boot Gradle plugin has been rewritten. Apply the plugin and the dependency‑management plugin explicitly:
<ol>
<li><code>apply plugin: 'org.springframework.boot'</code></li>
<li><code>apply plugin: 'io.spring.dependency-management' // add this to your build.gradle</code></li>
</ol>Key Spring Boot 2.0 Changes
Default Dynamic Proxy Strategy
CGLIB is now the default for class‑based proxies. To use interface‑based proxies, set spring.aop.proxy-target-class=false.
Web Application Type
The deprecated spring.main.web-environment property is replaced by spring.main.web-application-type. To disable the web server, set it to none or call SpringApplication.setWebApplicationType(...).
Application Events
A new ApplicationStartedEvent is published after the context is refreshed but before command‑line runners execute. ApplicationReadyEvent now signals that the application is ready to serve requests.
Banner Configuration
Banner‑related properties have been moved to the spring.banner namespace.
Relaxed Binding
Relaxed binding now supports kebab‑case, camelCase, and snake_case for property names, and environment variables must use upper‑case with underscores. The old RelaxedPropertyResolver and RelaxedDataBinder classes have been removed in favor of the new Binder API.
Embedded Servlet Container Refactoring
EmbeddedServletContainerhas been renamed to WebServer. Packages have moved from org.springframework.boot.context.embedded to org.springframework.boot.web.embedded. For example, replace TomcatEmbeddedServletContainerFactory with TomcatServletWebServerFactory.
Servlet‑Specific Server Properties
All server.* servlet properties have been moved under server.servlet.*. Example mappings: server.context-path →
server.servlet.context-path server.jsp.class-name→
server.servlet.jsp.class-name server.servlet-path→
server.servlet.pathWeb Starter Dependencies
Spring Boot 2.0 no longer pulls in WebFlux‑related starters automatically. Choose the appropriate starter ( spring-boot-starter-web or spring-boot-starter-webflux) yourself.
Template Engine Extensions
Mustache templates now use the .mustache suffix by default; adjust spring.mustache.suffix if needed.
Jackson / JSON
Jackson now writes dates as ISO‑8601 strings. To revert to timestamps, set spring.jackson.serialization.write-dates-as-timestamps=true. The spring-boot-starter-json starter bundles the necessary Jackson modules.
Spring MVC Path Matching
Suffix‑based path matching is disabled by default. Set spring.mvc.pathmatch.use-suffix-pattern to true if the old behavior is required.
Servlet Filter Dispatcher Type
Filters now default to DispatcherType.REQUEST, matching the Servlet specification.
RestTemplateBuilder
The requestFactory method now accepts a Supplier<ClientHttpRequestFactory>, allowing each template to use its own factory.
WebJars Locator
The old webjars-locator core library has been renamed; update dependencies accordingly.
Security Simplification
Adding a custom WebSecurityConfigurerAdapter disables most auto‑configuration. Security properties have moved under the security namespace. The default user now has a generated password and can be customized via spring.security.user.*.
Actuator Overhaul
Actuator endpoints are now under /actuator by default. Configuration keys have moved from endpoints.* to management.endpoint.* and management.endpoints.web.*. The base path can be changed with management.endpoints.web.base-path. Endpoint exposure is controlled via management.endpoints.web.exposure.include and management.endpoints.web.exposure.exclude. The health endpoint now uses management.endpoint.health.show-details to control detail visibility.
Metrics Migration
Spring Boot’s native metrics have been replaced by Micrometer. Use MeterRegistry or static Metrics.counter(...) calls to create custom metrics.
Developer Tools
Spring Loaded support has been removed; use Spring Boot DevTools instead. Remote HTTP tunnel debugging has also been dropped.
Removed Features
CRaSH support, Spring Mobile, Spring Social auto‑configuration, and the commons-digester dependency management have been removed.
Dependency Versions
Spring Boot 2.0 requires newer versions of key libraries: Spring Framework 5, Spring Security 5, Hibernate 5.2, Elasticsearch 5.6+, Jetty 9.4, Tomcat 8.5, and Gradle 4.
Reference
For the full migration guide, see the official repository: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
