SpringBoot2.6新特性详解

      SpringBoot2.6新特性详解

      SpringBoot2.5新特性详解

      SpringBoot2.4新特性详解

      SpringBoot2.3新特性详解

      SpringBoot2.2新特性详解

1、默认禁止的循环引用

现在默认禁止 bean 之间的循环引用

@Service
public class AService {
    @Resource
    private BServiec bServiec;
}
@Service
public class BServiec {
    @Resource
    private AService aService;
}

报错

The dependencies of some of the beans in the application context form a cycle:

┌─────┐
|  AService
↑     ↓
|  BServiec
└─────┘

如果想要关闭循环引用,则配置文件

spring.main.allow-circular-references=true

2. 端点新增运行时 Java 信息

management.endpoints.web.exposure.include=info
management.info.java.enabled=true

{
  "java": {
    "vendor": "Oracle Corporation",
    "version": "1.8.0_241",
    "runtime": {
      "name": "Java(TM) SE Runtime Environment",
      "version": "1.8.0_241-b07"
    },
    "jvm": {
      "name": "Java HotSpot(TM) 64-Bit Server VM",
      "vendor": "Oracle Corporation",
      "version": "25.241-b07"
    }
  }
}

3. 默认禁用执行器环境信息

management.info.env.enabled=true

可通过该链接了解 SpringBoot Actoator

4. Redis 连接池

 commons-pool2 在类路径下时,Redis(包括:Jedis 和 Lettuce)支持自动开启连接池。

也可以设置禁用连接池:

spring.redis.jedis.pool.enabled=false

spring.redis.lettuce.pool.enabled=false

5. 启动信息新增指标

application.started.time: 启动应用程序所需的时间
application.ready.time:  启动应用到对外提供服务所需时间

6. 磁盘空间指标

disk.free  磁盘空闲
disk.total  磁盘总空间

7. SpringMVC 默认路径匹配策略

Spring MVC 处理程序映射匹配请求路径的默认策略已从 AntPathMatcher 更改为PathPatternParser

PathPattern 性能比 AntPathMatcher 好。理论上 pattern 越复杂,PathPattern 的优势越明显

如果需要将默认值切换回 AntPathMatcher,可设置如下属性

spring.mvc.pathmatch.matching-strategy=ant-path-matcher

8. 构建信息个性化

通过 spring-boot-maven-plugin 支持自动生成此次构建信息的build-info.properties

    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <configuration>
           <excludeInfoProperties>
            <excludeInfoProperty>version</excludeInfoProperty>
         </excludeInfoProperties>
      </configuration>
    </plugin>

9. 移除2.4中的属性

 

Spring MVC 和 servlet 部分属性已被删除

旧属性(已删除) 新属性
spring.web.locale spring.mvc.locale
spring.web.locale-resolver spring.mvc.locale-resolver
spring.web.resources.* spring.resources.*
management.server.base-path management.server.servlet.context-path

10. 支持配置 Cookie SameSite 

Strict 严格模式,必须同站请求才能发送 cookie

Lax 宽松模式,安全的跨站请求可以发送 cookie

None 禁止 SameSite 限制,必须配合 Secure 一起使用(浏览器最后的坚持)

 

server.servlet.session.cookie.same-site=lax
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章