Spring Cloud 2022.0.0 发布子项目更新并支持 JDK 17 基线

Spring Cloud 2022.0.0 (Kilburn) 发布总结

VMware 发布了 Spring Cloud 2022.0.0,代号为 Kilburn,该版本对多个 Spring Cloud 子项目进行了更新。该版本基于 2022 年 11 月发布的 Spring Framework 6 和 Spring Boot 3 构建,支持 Java 17 并与 Jakarta EE 9 兼容。此外,该版本支持 GraalVM 的 AOT(Ahead of Time)编译和原生镜像生成。

主要更新内容

Spring Cloud Commons

  • 新增了加权负载均衡功能,通过配置 spring.cloud.loadbalancer.configurationsweighted 实现。
  • OAuth 集成现在使用 Spring Security 的新 OAuth2 支持。

Spring Cloud Gateway

  • 支持 Micrometer 作为 Spring Cloud Sleuth 的替代方案,用于可观测性。
  • 可以通过 spring.cloud.gateway.globalcors.enabled 属性全局禁用 CORS,并可以通过 cors 键在每个路由的元数据中配置 CORS。

Spring Cloud Kubernetes

  • 支持 fabric8 6.2.0 和 Kubernetes Java Client 17。
  • 将 Kubernetes 特有的注解 @ConditionalOnKubernetesEnabled 替换为更通用的 @ConditionalOnCloudPlatform
  • 分别读取基于名称和基于标签的 secrets 和 configmaps,以避免潜在问题。
  • DiscoveryClient 现在支持按命名空间过滤服务发现,以防止访问受限命名空间时出现异常。

Spring Cloud Contract

  • 不再默认支持 Pact,因为 Pact 破坏了二进制和功能兼容性。可以通过迁移指南将现有应用升级到最新版本。

Spring Cloud OpenFeign

  • 宣布功能完成,不再添加新功能,但仍会修复安全问题和 bug,并考虑社区的次要 pull request。
  • Spring Framework 6.0 引入了 HTTP Interface,将用于替代 OpenFeign。

其他变动

  • Spring Cloud CLI、Spring Cloud Cloudfoundry 和 Spring Cloud Sleuth 不再包含在发布序列中。

使用方式

要在项目中使用 Spring Cloud 2022.0.0,可以在 Maven 的 POM 文件中添加以下配置:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>2022.0.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
</dependencies>

或使用以下 Gradle 配置:

plugins {
  id 'java'
  id 'org.springframework.boot' version '3.0.0'
  id 'io.spring.dependency-management' version '1.1.0'
}
repositories {
  mavenCentral()
}
ext {
  set('springCloudVersion', "2022.0.0")
}
dependencies {
  implementation 'org.springframework.cloud:spring-cloud-starter-config'
  implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
}

dependencyManagement {
  imports {
    mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
  }
}

反馈与支持

有关此版本的破坏性更改可以在 发布说明 中查看。用户可以通过 GitHubGitterStack OverflowTwitter 提供反馈。

阅读 68
0 条评论