2

These days are Spring version days, many Spring artifacts have new versions released, Spring Framework 6.0.0 has released its 4th milestone release, this release contains all the fixes for 5.3.20, and 39 items specific to the 6.0 branch Fixes and improvements. Today, Spring Boot 2.7.0 and a branch of Spring Security have released new versions, especially Spring Boot 2.7.0 , which is a very important version.

Spring Boot 2.7.0

The most important thing today is the release of Spring Boot 2.7.0 , which adds a lot of new features and improvements and is a very important release. Too many things to pick and focus on.

Changes to automatic configuration

Spring Boot 2.7.0 made no small changes to auto-configuration.

Automatic configuration registration

The fully qualified name of the Spring auto-configuration class is now in META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports .; it used to be in META-INF/spring.factories . Still backwards compatible, both of them will work, but loading autoconfiguration from spring.factories is not recommended.

New @AutoConfiguration annotation

Introduced new @AutoConfiguration annotation. This class is used to declare the AutoConfig class in the autoconfiguration registry above. It replaces @Configuration and is only available for the autoconfiguration class.你afterafterNamesbeforebeforeNames @AutoConfigureAfter @AutoConfigureBefore

 @AutoConfiguration(after = SecurityAutoConfiguration.class)
@ConditionalOnWebApplication(type = Type.SERVLET)
@EnableConfigurationProperties(SecurityProperties.class)
@ConditionalOnClass({ AbstractSecurityWebApplicationInitializer.class, SessionCreationPolicy.class })
public class SecurityFilterAutoConfiguration {
 
}

Test automation configuration

If you create your own automated configuration class test, you should also configure the automated configuration class by referring to the automatic configuration registration method above. Refer to the spring-boot-test-autoconfigure module in the Spring Boot project.

@SpringBootTest configuration item priority

Now you can add test attributes via @SpringBootTest 's properties attribute or @TestPropertySource annotation, which takes precedence over commands passed to args attribute.

New Flyway module

Spring Boot 2.7 upgrade to Flyway 8.5 (from 8.0). Since version 8.0, Flyway 's support for multiple databases has been extracted into new modules:

  • flyway-firebird (Firebird)
  • flyway-mysql (MariaDB and MySQL)
  • flyway-sqlserver (SQL Server)

    If you use Flyway to manage the above database, please add the dependencies of the corresponding new modules.

Version 2.1 of the H2 database

Spring Boot 2.7 has been upgraded to H2 2.1.120 . H2 2.x is backwards incompatible and fixes many security holes.

OkHttp 4

Since OkHttp 3 is no longer maintained, Spring Boot 2.7 has been upgraded to OkHTTP 4 . As part of this upgrade, the property used to control the OkHttp version has been changed from okhttp3.version to okhttp.version . If you want to use OkHttp 3 , please modify it to the corresponding version.

Support for Elasticsearch's RestHighLevelClient is deprecated

Elasticsearch has deprecated its RestHighLevelClient . In line with this, Spring Boot's autoconfiguration RestHighLevelClient has been deprecated. Where possible, the auto-configured low-level RestClient should be used. Alternatively, consider manually configuring new clients .

Deprecation of Spring Boot 2.5

Classes, methods, and properties that were deprecated in Spring Boot 2.5 have been removed in this release. Make sure you are not calling outdated methods before upgrading.

Note: Spring Boot version 2.5 has discontinued OSS support and no longer provides free security updates and bug fixes.

Spring GraphQL support

Spring Boot 2.7 now supports Spring GraphQL , and the corresponding starter is spring-boot-starter-graphql . GraphQL is a query language for APIs and a language that can satisfy data queries.

Opaque token introspection optimization

If you are using opaque token introspection in the OAuth2 resource server, auto-configured introspection no longer requires a dependency on com.nimbusds:oauth2-oidc-sdk . You can remove this dependency from your application.

Couchbase and Elasticsearch test annotations

Added @DataCouchbaseTest and @DataElasticsearchTest to test Couchbase and Elasticsearch databases respectively.

Podman Support

The Maven and Gradle plugins now support using the Podman container engine as an alternative to the Docker engine when building images with Cloud Native Buildpacks.

Is Docker not fragrant?

Cache2k support

Added dependency management and auto-configuration for cache Cache2k . The default cache settings can be customized by defining the Cache2kBuilderCustomizer bean.

Jackson Mixin Simplified Registration

Jackson's auto-configuration will now scan your application bundle for Mixin classes annotated with @JsonMixin and register with ObjectMapper .

other

There are other dependency upgrades, see the official release notes for details.

Spring Security

Yesterday , Spring Security 5.7.1, 5.6.5, 5.5.8 were released one after another, before the M5 release of Spring Security 6.6.0 .

Summarize

Now the version iteration is getting faster and faster, and we need to keep up with the pace. If we don’t pay attention, we will fall behind a lot. The pressure of learning is really big. I will study the new version, but now I feel powerless, too fast .

关注公众号:Felordcn 获取更多资讯

Personal blog: https://felord.cn


码农小胖哥
3.8k 声望8k 粉丝