springCloud and springboot upgrade

I. Introduction

      Lower versions of springCloud and springBoot sometimes have network vulnerabilities, so these vulnerabilities will be fixed as springCloud and springBoot are upgraded. Then sometimes we encounter incompatibility problems during the upgrade process. It needs to be summarized and recorded.

2. Use of springBoot and springCloud

1. Reference to springBoot

We can introduce springboot in the pom of the springboot parent project, which means using version 2.6.2 of springboot. The blogger used version 2.5.2 before. 2.6.2 is the upgraded version.

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.2</version>
    </parent>

2. After introducing the parent dependency, we can introduce springboot in any child module

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

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

3. For springCloud references, 2021.0.1 is used here, which is also the upgraded version. Previously, 2020.0.3 was used.

 <spring-cloud.version>2021.0.1</spring-cloud.version>

Commonly used springCloud dependencies

(1), gateway

       <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
          
        </dependency>

(2) Other procedures

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bootstrap</artifactId>
        </dependency>

 (3)feign

 <dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-openfeign</artifactId>
		</dependency>

(4)eureka

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.thoughtworks.xstream</groupId>
                    <artifactId>xstream</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

For springboot 2.6.2 and springCloud 2021.0.1 versions that are compatible with other component versions, please refer to

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <base.version>1.0-SNAPSHOT</base.version>
        <java.version>1.8</java.version>
        <spring-cloud.version>2021.0.1</spring-cloud.version>
        <spring-boot.version>2.6.2</spring-boot.version>
        <mysql.version>8.0.17</mysql.version>
        <druid.version>1.1.13</druid.version>
        <mybatisplus.version>3.4.3.4</mybatisplus.version>
        <mybatis-spring.version>2.2.0</mybatis-spring.version>
        <apollo.version>1.8.0</apollo.version>
        <dameng.version>7.6.0.142</dameng.version>
        <fastjson.version>1.2.83</fastjson.version>
        <swagger2.version>2.9.2</swagger2.version>
        <hutool.version>5.7.7</hutool.version>
        <poi.version>4.1.2</poi.version>
        <commons-lang3.version>3.8.1</commons-lang3.version>
        <xstream.version>1.4.18</xstream.version>
        <log4j-to-slf4j.version>2.15.0</log4j-to-slf4j.version>
        <java-jwt.version>3.8.2</java-jwt.version>
        <zxing.version>3.3.0</zxing.version>
        <barcode4j.version>2.1</barcode4j.version>
        <bcprov-jdk15to18.version>1.66</bcprov-jdk15to18.version>
        <rocketmq.version>4.7.1</rocketmq.version>
        <mq-http-sdk.version>1.0.3.2</mq-http-sdk.version>
        <aliyun-sdk-oss.version>3.13.2</aliyun-sdk-oss.version>
        <cos_api.version>5.6.89</cos_api.version>
        <sharding-sphere.version>4.0.0-RC2</sharding-sphere.version>
		<shardingsphere.version>5.0.0-beta</shardingsphere.version>
    </properties>

3. Issues to note when upgrading springboot and springCloud

If there are circular dependencies in the previous code, you need to configure the yml to ignore the dependencies, otherwise an error will be reported when the project is started, and the mvn package cannot be packaged.

Error message:

Description:

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

Tip processing method:

Action:

Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
 

It can be solved in yml configuration

spring:
#spring boot 升级到2.6.x后需要增加的配置
  main:
    allow-circular-references: true
  mvc:
    pathmatch:
      matching-strategy: ANT_PATH_MATCHER

Guess you like

Origin blog.csdn.net/dongjing991/article/details/133312966