How to Upgrade Spring Cloud Tencent to 2022: A Step‑by‑Step Guide

This article walks developers through upgrading Spring Cloud Tencent to the 2022 release, covering JDK 17 installation, Maven dependency updates, handling package conflicts, migrating javax to jakarta imports, adapting auto‑configuration files, and provides practical tips for a smooth transition to Java 17, Spring 6, and Spring Boot 3.

Programmer DD
Programmer DD
Programmer DD
How to Upgrade Spring Cloud Tencent to 2022: A Step‑by‑Step Guide

Preface

Java 8 is still widely used in production in China, but many have moved to Java 11/17. However many developers still cling to Java 8. Java 17 brings performance improvements, especially ZGC, prompting upgrades.

Spring Framework 5 has been around for five years; a major version is needed. With Java 17, the new stack "Java 17 + Spring Framework 6.0 + Spring Boot 3.0 + Spring Cloud 2022" is expected to become mainstream.

Spring Cloud Tencent is an all‑in‑one micro‑service solution based on Tencent’s Polaris platform, providing registration, configuration, rate limiting, etc., and has been quickly adapted to Spring Cloud 2022. This article details the changes required to upgrade Spring Cloud Tencent from the 2021 version to 2022.

1. Upgrade Process

1.1 Install JDK 17

Download JDK 17 from Oracle and set JAVA_HOME accordingly.

#echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-17.0.5.jdk/Contents/Home
#java -version
java version "17.0.5" 2022-10-18 LTS
Java(TM) SE Runtime Environment (build 17.0.5+9-LTS-191)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.5+9-LTS-191, mixed mode, sharing)

After installation, configure the project SDK to 17 in IntelliJ IDEA.

1.2 Upgrade Dependency Versions

The project uses the parent pom spring-cloud-build, which must be upgraded to the latest version.

<parent>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-build</artifactId>
  <version>4.0.0-RC2</version>
  <relativePath/>
</parent>

Spring‑cloud‑build 4.0.0‑RC2 defines Java 17 and Spring Boot 3.0 as the default versions.

<properties>
  <java.version>17</java.version>
  <spring-boot.version>3.0.0-RC2</spring-boot.version>
</properties>

If the project defines its own versions, update them as follows:

<properties>
  <java.version>17</java.version>
  <spring.framework.version>6.0.1</spring.framework.version>
  <spring-boot.version>3.0.0</spring-boot.version>
  <spring.cloud.version>2022.0.0-RC2</spring.cloud.version>
</properties>
<dependencyManagement>
  <dependencies>
    <!-- Spring Framework -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-framework-bom</artifactId>
      <version>${spring.framework.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
    <!-- Spring Boot -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-dependencies</artifactId>
      <version>${spring.boot.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
    <!-- Spring Cloud -->
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-dependencies</artifactId>
      <version>${spring.cloud.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

Non‑GA Spring versions are published to Spring’s own Maven repository; add the repository configuration if needed.

<repositories>
  <repository>
    <id>spring-snapshots</id>
    <name>Spring Snapshots</name>
    <url>https://repo.spring.io/snapshot</url>
    <snapshots><enabled>true</enabled></snapshots>
    <releases><enabled>false</enabled></releases>
  </repository>
  <repository>
    <id>spring-milestones</id>
    <name>Spring Milestones</name>
    <url>https://repo.spring.io/milestone</url>
    <snapshots><enabled>false</enabled></snapshots>
    <releases><enabled>true</enabled></releases>
  </repository>
</repositories>

During the upgrade you may encounter dependency conflicts, such as a mismatch between SCT’s logback version (1.2.11) and the version brought in by Spring Boot 3.0 (1.4.5). Resolve by removing the explicit version and relying on the transitive one.

Tip: Resolving version conflicts can be time‑consuming; be patient.

1.3 Replace Incompatible Code

All javax imports must be changed to jakarta because Java 17 removes the former package.

Spring Web 6.0 introduces API changes, e.g., ClientHttpResponse.getStatusCode() now returns HttpStatusCode instead of HttpStatus.

1.4 Update Auto‑Configuration

Before Spring Boot 3.0, auto‑configuration classes were listed in META-INF/spring.factories. In 3.0 they are declared in

META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

. Move the entries accordingly.

org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.tencent.cloud.plugin.pushgateway.PolarisStatPushGatewayAutoConfiguration

Only the EnableAutoConfiguration entries need migration; other entries stay in spring.factories.

1.5 Upgrade Summary

SCT has few third‑party dependencies, so the overall migration effort is modest. Projects with many additional components (e.g., Spring Security, Spring Stream) will face higher costs.

Key points from community feedback:

After switching to JDK 17, some third‑party libraries need version adjustments.

Replace outdated code; watch for changes in Spring Security 6.

Different auto‑configuration registration formats cause most failures.

Reflection behavior may differ on JDK 17.

Underlying component upgrades may lag behind, causing compile issues.

Maintaining backward compatibility adds complexity.

Spring recommends a small‑step upgrade: first to Spring Boot 2.7, then to 3.0, to ensure a smoother transition.

2. Trying Spring Cloud Tencent 2022.0

Spring Cloud Tencent 1.8.1‑2022.0.0 is available. Add the SCT BOM to your pom as shown:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.tencent.cloud</groupId>
      <artifactId>spring-cloud-tencent-dependencies</artifactId>
      <version>1.8.1-2022.0.0-RC2</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

SCT version numbers align with the corresponding Spring Cloud version; choose the SCT version that matches your Spring Cloud release.

3. Call for Collaboration

Upgrading foundational components directly impacts downstream applications. Maintainers are encouraged to keep pace with adaptations to help developers adopt new versions quickly.

4. Join the Community

If you are interested in micro‑services and Spring Cloud, you are welcome to contribute via issues, pull requests, or simply starring the repository.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Spring BootupgradeSpring Cloudjava-17
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.