spring boot2.3.10升级到spring boot 2.4.3后服务无法访问
时间: 2023-10-30 16:32:30 浏览: 40
可能是升级导致的配置问题,建议检查以下几个方面:
1. 检查pom.xml文件,确保引入的Spring Boot版本正确;
2. 检查application.properties或application.yml文件,确保配置项没有变化,特别是数据库、端口号等配置;
3. 检查代码中的依赖注入、自动装配等相关代码是否需要调整;
4. 检查日志输出,查看是否有具体的错误提示,进一步排查。
相关问题
spring boot2.3.10升级到spring boot 2.4.3改动
1. 引入新的依赖
在pom.xml文件中引入Spring Boot 2.4.3版本的依赖:
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.4.3</version>
</dependency>
```
2. Application.properties文件更改
在application.properties文件中,需要更改的地方如下:
```properties
spring.main.allow-bean-definition-overriding=true
```
这个属性是Spring Boot 2.4.3中新增的,用于允许Bean定义的覆盖。在Spring Boot 2.3.10中默认是false。
3. 日志配置更改
在Spring Boot 2.4.3中,日志框架从Logback改为了Log4j2。如果之前使用的是Logback,需要将其依赖移除,并添加Log4j2的依赖:
```xml
<!--移除Logback依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--添加Log4j2依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.4.3</version>
</dependency>
```
同时,需要将application.properties文件中的日志配置改为Log4j2的日志配置。
4. 引入新的特性
Spring Boot 2.4.3中引入了一些新的特性,比如:
- 优化了响应式编程的支持;
- 支持Java 15;
- 支持JDBC的异步执行;
- 支持配置文件中的if条件判断等。
可以根据实际情况,选择使用这些新特性。
5. 单元测试更改
在Spring Boot 2.4.3中,JUnit 5成为了默认的测试框架,因此需要修改测试类的引入:
```java
import org.junit.jupiter.api.Test;
```
同时,需要将Gradle或Maven中的JUnit依赖改为JUnit 5的依赖。
6. 其他更改
在Spring Boot 2.4.3中,一些类和方法进行了更改,比如:
- DataSourceProperties类中的url属性改为jdbc-url;
- RestTemplateBuilder类中的build()方法改为buildRestTemplate()方法。
需要根据实际情况进行修改。
springcloud和springboot版本对应关系
下面是常见的 Spring Cloud 和 Spring Boot 版本对应关系:
|Spring Cloud 版本|Spring Boot 版本|
|---|---|
|Spring Cloud 2020.0.x|Spring Boot 2.4.x|
|Spring Cloud Hoxton.SR9|Spring Boot 2.3.10|
|Spring Cloud Hoxton.SR8|Spring Boot 2.3.9|
|Spring Cloud Hoxton.SR7|Spring Boot 2.3.8|
|Spring Cloud Hoxton.SR6|Spring Boot 2.2.9|
|Spring Cloud Hoxton.SR5|Spring Boot 2.2.7|
|Spring Cloud Hoxton.SR4|Spring Boot 2.2.6|
|Spring Cloud Hoxton.SR3|Spring Boot 2.2.5|
|Spring Cloud Hoxton.SR2|Spring Boot 2.2.4|
|Spring Cloud Hoxton.SR1|Spring Boot 2.2.1|
|Spring Cloud Greenwich.SR5|Spring Boot 2.1.13|
|Spring Cloud Greenwich.SR4|Spring Boot 2.1.12|
|Spring Cloud Greenwich.SR3|Spring Boot 2.1.11|
|Spring Cloud Greenwich.SR2|Spring Boot 2.1.10|
|Spring Cloud Greenwich.SR1|Spring Boot 2.1.9|
需要注意的是,这只是一个大体上的对应关系,具体的版本兼容性还需要查阅文档或者官方发布的公告。同时,也需要根据实际情况进行版本选择,不一定非得按照这个对应关系。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)