Key New Features in Spring Boot 2.6.0 Release
Spring Boot 2.6.0 introduces several important backend enhancements, including mandatory circular‑dependency detection, custom sanitizing rules, default Redis connection‑pool activation, WebTestClient MVC testing support, a new path‑matching strategy, enriched /info endpoint data, and various other improvements.
Spring Boot 2.6.0 has been officially released, bringing several important upgrades for backend developers.
1. Circular Dependency Prohibition
Circular dependencies, a common interview topic, are now prohibited by default; if a cycle exists the application fails to start with an error message suggesting the use of spring.main.allow-circular-references=true as a last resort.
┌─────┐
| a (field private com.zhiyin.TestB com.zhiyin.TestA.b)
↑ ↓
| b (field private com.zhiyin.TestA com.zhiyin.TestB.a)
└─────┘
Action:
Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
To allow the cycle, add the following property to application.properties: spring.main.allow-circular-references = true The application can then start normally.
2. Custom Sanitizing Rules
Spring Boot 2.6.0 supports custom sanitizing for the /env endpoint and configprops by defining a bean of type SanitizingFunction.
@Bean
public SanitizingFunction pwdSanitizingFunction() {
return data -> {
org.springframework.core.env.PropertySource<?> propertySource = data.getPropertySource();
String key = data.getKey();
// Only sanitize certain keys in redis.properties
if (propertySource.getName().contains("redis.properties")) {
if (key.equals("redis.pwd")) {
return data.withValue(SANITIZED_VALUE);
}
}
return data;
};
}This provides flexible data masking.
3. Redis Connection Pool Enabled by Default
Previously, enabling a Redis connection pool required manual configuration; from 2.6.0 it is on by default. To disable it, set one of the following properties: spring.redis.jedis.pool.enabled = false or
spring.redis.lettuce.pool.enabled = false4. WebTestClient Support for MVC Testing
Developers can use WebTestClient in mock environments by adding the @AutoConfigureMockMvc annotation, simplifying test code.
5. New Path Matching Strategy
The default path‑matching strategy switched from AntPathMatcher to PathPatternParser. It can be reverted by setting spring.mvc.pathmatch.matching-strategy=ant-path-matcher. The new parser retains compatibility except for the unsupported “**” pattern, and adds support for {*pathVariable}.
public static class Pathmatch {
private MatchingStrategy matchingStrategy =
MatchingStrategy.ANT_PATH_MATCHER;
} public static class Pathmatch {
private MatchingStrategy matchingStrategy =
MatchingStrategy.PATH_PATTERN_PARSER;
}6. Enhanced /info Endpoint
The /info endpoint now includes detailed Java runtime information, for example:
{
"java": {
"vendor": "BellSoft",
"version": "17",
"runtime": {
"name": "OpenJDK Runtime Environment",
"version": "17+35-LTS"
},
"jvm": {
"name": "OpenJDK 64-Bit Server VM",
"vendor": "BellSoft",
"version": "17+35-LTS"
}
}
}7. Other Changes
Servlet applications now support the SameSite attribute on cookies.
Health groups can be configured on the main or management port.
Classes, methods, and properties deprecated in Spring Boot 2.4 have been removed.
Log4j2 composite configuration is now supported.
Build‑info property exclusions are supported.
Note that Spring Boot releases two minor versions each year with one‑year free support; version 2.4.x is no longer supported.
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.
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
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.
