Spring Boot 2.6 发布了和一些重要变更!!

595 阅读2分钟

图片

等了很久 Spring Boot 2.6 终于发布了 !!看看有哪些东西吧

新的特性

  • Servlet应用现在支持在Cookie中添加SameSite。

  • 支持在主端口或管理端口上配置健康组。

  • 增强了/info管理端点,加上了Java运行时信息。

pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

application.properties

# 暴露 info 端点
management.endpoints.web.exposure.include=info
management.info.java.enabled=true

图片

  • metrics 端点暴露启动和磁盘空间信息

application.properties

management.endpoints.web.exposure.include=metrics

图片

获取某个具体的指标的详细信息: http://localhost:8080/actuator/metrics/{MetricName} 。

图片

  • 支持使用WebTestClient来测试Spring MVC

    WebTestClient 主要是为了测试 Spring WebFlux 项目,这次改版之后,WebTestClient 已经支持普通的 Spring MVC 项目。

@SpringBootTest
@AutoConfigureWebTestClient
class MyMockWebTestClientTests {
    @Autowired
    WebTestClient webClient;

    @Test
    void helloWorldTest() {
        webClient
                .get().uri("/hello")
                .exchange()
                .expectStatus().isOk()
                .expectBody(String.class).isEqualTo("Hello World!");
    }
}
  • 为spring-rabbit-stream模块增加Spring Boot默认自动配置。

  • 支持对/env端点和configprops配置项中的属性添加可插拔的脱敏规则。

重要变更

  • 在 Spring Boot 2.4 中弃用的类、方法和属性已在此版本中删除。

  • 现在默认禁止Spring Bean之间的循环引用,如果直接使用会报错,需要开启如下设置:

spring.main.allow-circular-references=true
  • 请求路径与 Spring MVC 处理映射匹配的默认策略已从AntPathMatcher更改为PathPatternParser。你可以设置spring.mvc.pathmatch.matching-strategy为ant-path-matcher来改变它。

spring.mvc.pathmatch.matching-strategy=ant-path-matcher
  • Spring Boot 2.4 停止维护

    这次Spring Boot 2.6应该是年前最重要的更新了,东西非常多。但是最劲爆的消息是Spring Boot 2.4 停止支持,是的从美东时间2021-11-18开始Spring Boot 2.4停止支持。并且官方给出了1.5.x到2.7.x的生命周期时间表:

图片

图片

点击下方卡片/微信搜索,关注公众号“天宇文创意乐派”(ID:gh_cc865e4c536b)

听说点赞和关注本号的都找到漂亮的小姐姐了哟且年后必入百万呀!!

往期推荐

[

@Transactional 错误集锦以及如何正确使用

](mp.weixin.qq.com/s?__biz=MzI…)

[

只需一行CSS代码,让长列表网页的渲染性能提升几倍以上!

](mp.weixin.qq.com/s?__biz=MzI…)

[

某APP订单系统的设计分享|干货!

](mp.weixin.qq.com/s?__biz=MzI…)

[

JavaScript 细节和一些实际应用,了解一下

](mp.weixin.qq.com/s?__biz=MzI…)

本文使用 文章同步助手 同步