spring boot2.3.10升级到spring boot 2.4.3改动
时间: 2023-12-01 09:03:09 浏览: 50
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()方法。
需要根据实际情况进行修改。
相关推荐
![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)
![](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)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)