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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章