Spring Boot 3.1 is officially released, Wang Zha! !

Spring Boot 3.1 officially released

Hello everyone, I am Brother R.

Previous: Spring Boot 3.0 is officially released, Wang Zha! !

About half a year after Spring Boot 3.0 was released, Spring Boot 3.1 was officially released:

At the same time, the 2.7.x version was also released. At the same time, Brother R noticed that the 2.6.x version line has stopped maintenance. The latest supported version is shown in the figure below:

2.7.x This is the only 2.x version line currently being maintained, and the commercially supported version is only 2.5.x.

If you haven't used Spring Boot, here is the latest book " Spring Boot 3 Core Technology and Best Practice " by Brother R , including the underlying implementation principles and code combat. links.

Major new features of Spring Boot 3.0

Brother R took a look, and Spring Boot 3.1 has updated a lot of content. Today, Brother R will briefly share a few important updates.

1. Minimum environmental requirements

The release of Spring Boot 3.0 requires Java 17 as a minimum, and supports Java 19 for upward compatibility. Spring Boot 3.1 can support Java 20, because Java 20 was released some time ago.

Comparison table of requirements for Java development environment:

Spring Boot JDK Spring Maven Gradle
3.1.0 17 ~ 20 6.0.9+ 3.6.3+ 7.5+,8.x
3.0.0 17 ~ 19 6.0.2+ 3.5+ 7.5+
2.7.12 8 ~ 20 5.3.27+ 3.5+ 6.8.x, 6.9.x, 7.x, 8.x

2. A lot of reliance on upgrades

The minimum supported Spring framework of Spring Boot 3.1 has also become Spring 6.0.9+. In addition, a large number of third-party technical dependencies managed by Spring Boot have also been greatly upgraded. For details, please refer to the official version release document:

https://github.com/spring-projects/spring-boot/releases/tag/v3.1.0

The upgrade of the above technologies is also a roadblock for the upgrade of Spring Boot applications.

3. Remove HttpClient 4

Because Spring 6 removed RestTemplate's support for Apache HttpClient 4 and replaced it with Apache HttpClient 5.

However, Spring Boot 3.0 also includes the management of the two dependencies of HttpClient 4 and HttpClient 5. If these two versions are managed at the same time, some people may continue to use HttpClient 4, and the application may have potential errors when using RestTemplate. make diagnosis difficult.

Therefore, Spring Boot 3.1 removes the dependency management of HttpClient 4, and instead forces users to use HttpClient 5. Everyone needs to pay attention when upgrading to rely on HttpClient 4.

4. An exception is thrown when Servlet and Filter registration fails

As you know, the two classes ServletRegistrationBean and FilterRegistrationBean used by Spring Boot to register Servlets and Filters used to record warning-level logs when registration failed, but now throw IllegalStateException directly.

If you don't want to throw an exception when the registration fails, or want to record the warn warning log as before, you can call the setIgnoreRegistrationFailure(true) method of these two classes, that is, ignore the registration failure. The usage example is as follows:

@Bean
public ServletRegistrationBean registerServlet() {
    ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new RegisterServlet(), "/registerServlet");
    servletRegistrationBean.addInitParameter("type", "公众号");
    servletRegistrationBean.addInitParameter("name", "Java技术栈");
    servletRegistrationBean.setIgnoreRegistrationFailure(true);
    return servletRegistrationBean;
}

5. Spring Authorization Server automatic configuration

Spring Boot 3.1 provides a spring-boot-starter-oauth2-authorization-server starter, which can support the automatic configuration of Spring Authorization Server and easily configure the Servlet-based OAuth2 authorization server.

More reference official documents:

https://docs.spring.io/spring-boot/docs/3.1.0/reference/html/web.html#web.security.oauth2.authorization-server

6. Docker Compose new module

Docker Compose is a tool for defining and running multiple Docker containers, the official container orchestration tool, which can easily define dependencies, environment variables, network settings, etc. between multiple containers, and create them with one command , start and connect these containers.

Spring Boot 3.1 provides a new module: spring-boot-docker-compose, which supports integration with Docker Compose, and when a Spring Boot application starts, it looks for configuration files in the current working directory.

The following configuration files are supported:

  • compose.yaml
  • compose.yml
  • docker-compose.yaml
  • docker-compose.yml

More reference official documents:

https://docs.spring.io/spring-boot/docs/3.1.0/reference/html/features.html#features.docker-compose

7. SSL configuration

SSL trust-related stuff like Java KeyStore and PEM-encoded certificates can now be configured using the properties property and can be applied to various types of connections, such as embedded web servers, data services, RestTemplate, and WebClient.

More reference official documents:

https://docs.spring.io/spring-boot/docs/3.1.0/reference/html/features.html#features.ssl

8. Service connection

Spring Boot 3.1 introduces a new service connection concept, which is a low-level feature intended to serve as a building block for other high-level features that can automatically configure a service connection by defining a ConnectionDetails Bean.

The ConnectionDetails Bean provides the detailed information needed to establish and delete service connections, and Spring Boot's automatic configuration has also been supported. When these beans are available, they will take precedence over any connection-related configuration parameters. However, nothing to do with the connection itself Configuration parameters (such as those controlling connection pool size and behavior) will still be used.

The latest supported version of Spring Boot

Brother R sorted out the latest version support of Spring Boot:

Version release time downtime stop commercial support
3.1.x 2023-05-18 2024-05-18 2025-08-18
3.0.x 2022-11-24 2023-11-24 2025-02-24
2.7.x 2022-05-19 2023-11-18 2025-02-18
2.6.x 2021-12-17 2022-11-24 2024-02-24
2.5.x 2021-05-20 stopped 2023-08-24
2.4.x 2020-11-12 stopped 2023-02-23
2.3.x 2020-05-15 stopped stopped
2.2.x 2019-10-16 stopped stopped
2.1.x 2018-10-10 stopped stopped
2.0.x 2018-03-01 stopped stopped
1.5.x 2017-01-30 stopped stopped

By the way, which Spring Boot version are you using?

If you have not used Spring Boot, finally recommend the latest book " Spring Boot 3 Core Technology and Best Practice " by Brother R , including the underlying implementation principles and code combat. links.

The latest and most complete actual combat code of Spring Boot has been uploaded to Github:

https://github.com/javastacks/spring-boot-best-practice

Well, that’s all for today’s sharing. Brother R will continue to pay attention to and share more Spring Boot dry goods in the future, and pay attention to the public account Java technology stack to push it as soon as possible.

Copyright statement: This article is the original work of the public account "Java Technology Stack". Please indicate the source for reprinting and quoting the content of this article. Plagiarism and manuscript washing will all be complained of infringement, and the consequences will be at your own risk, and the right to pursue legal responsibility is reserved.

Recent hot article recommendation:

1. 1,000+ Java interview questions and answers (2022 latest version)

2. Brilliant! Java coroutines are coming. . .

3. Spring Boot 2.x tutorial, too comprehensive!

4. Don't fill the screen with explosions and explosions, try the decorator mode, this is the elegant way! !

5. The latest release of "Java Development Manual (Songshan Edition)", download quickly!

Feel good, don't forget to like + forward!

おすすめ

転載: blog.csdn.net/youanyyou/article/details/130826243