About the function of Spring Boot due to different versions

This is a continuation of Last time. This time it is about that the methods that can be used have changed due to Spring Boot 2.

change point

1.findOne The findOne method is used for the teaching material, but if you use this as it is, You will be prompted to make changes to the findById method. The return value is also Optional type.

Teaching materials (previous version)


public MeetingRoom findMeetingRoom(Integer roomId) {
	return meetingRoomRepository.findOne(roomId);
}

SpringBoot2 changes


public Optional<MeetingRoom> findMeetingRoom(Integer roomId) {

	return meetingRoomRepository.findById(roomId);
}

To get the value of Optional type, you need to add get ().

2.WebMvcConfigurerAdapter This is also deprecated. Use WebMvcConfigurer.

Teaching materials (previous version)


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter{
}

SpringBoot2 changes


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer{
}

Recommended Posts

About the function of Spring Boot due to different versions
The story of raising Spring Boot 1.5 series to 2.1 series
05. I tried to stub the source of Spring Boot
I tried to reduce the capacity of Spring Boot
The story of raising Spring Boot from 1.5 series to 2.1 series part2
I want to control the default error message of Spring Boot
About the initial display of Spring Framework
[Spring Boot] I investigated how to implement post-processing of the received request.
[Rails] About the error when displaying the screen due to the autofocus of the form
Procedure to make the value of the property file visible in Spring Boot
How to access Socket directly with the TCP function of Spring Integration
Summary of what I learned about Spring Boot
About the official start guide of Spring Framework
Let's check the feel of Spring Boot + Swagger 2.0
Try to implement login function with Spring Boot
[Spring Boot] How to refer to the property file
[Introduction to Spring Boot] Authentication function with Spring Security
Introducing the Spring Boot Actuator, a function that makes the operation of Spring Boot applications easier.
Resource handler settings when delivering SPA with the static resource function of Spring Boot
How to set environment variables in the properties file of Spring boot application
About the function double-java
About DI of Spring ①
About DI of Spring ②
A memorandum of addiction to Spring Boot2 x Doma2
Access the built-in h2db of spring boot with jdbcTemplate
How to use CommandLineRunner in Spring Batch of Spring Boot
Deploy the Spring Boot project to Tomcat on XAMPP
How to boot by environment with Spring Boot of Maven
[Comparison verification] How different is the development productivity of Spring Boot apps from the past?
About the handling of Null
Deploy Spring Boot applications to Heroku without using the Heroku CLI
About the description of Docker-compose.yml
A story packed with the basics of Spring Boot (solved)
[Swift] I tried to implement the function of the vending machine
[Java] Deploy the Spring Boot application to Azure App Service
Extract SQL to property file with jdbcTemplate of spring boot
Deploy the application created by Spring Boot to Heroku (public) ②
Introduction to Spring Boot ① ~ DI ~
A note about the seed function of Ruby on Rails
Introduction to Spring Boot ② ~ AOP ~
Deploy the application created by Spring Boot to Heroku (public) ①
Introduction to Spring Boot Part 1
Whether options can be used due to different Java versions
How to deal with different versions of rbenv and Ruby
I want to know the Method of the Controller where the Exception was thrown in the ExceptionHandler of Spring Boot
I want to understand the flow of Spring processing request parameters
Get a proxy instance of the component itself in Spring Boot
[Rails] Talk about paying attention to the return value of where
What I did in the migration from Spring Boot 1.4 series to 2.0 series
What I did in the migration from Spring Boot 1.5 series to 2.0 series
See the behavior of entity update with Spring Boot + Spring Data JPA
Rails tutorial When rails new cannot be done due to different versions
About the behavior of ruby Hash # ==
Memorandum of understanding when Spring Boot 1.5.10 → Spring Boot 2.0.0
About the basics of Android development
Spring Boot for the first time
[Rails] About the Punk List function
About error handling of comment function
How to set Spring Boot + PostgreSQL
[Rails] About implementation of like function
Going out of message (Spring boot)