聊聊springboot2.2.3升級到2.4.0單元測試的區(qū)別
springboot2.2.3升級到2.4.0單元測試區(qū)別
原先單元測試 import org.junit.Test; 然后運(yùn)行正常,現(xiàn)在運(yùn)行報錯,

import org.junit.Test;
換成
import org.junit.jupiter.api.Test;
后運(yùn)行正常。
單個單元測試的這樣沒有問題了,但是我批量執(zhí)行的還是會報上面的錯誤
@Suite.SuiteClasses({
//dao層測試類
//service層測試類
CheckConfigServiceTest.class,
AfterCheckConfigServiceTest.class,
//control層測試類
//WebTestControllerTest.class
//util測試類
})
@RunWith(Suite.class)
public class BatchTest {
}
最后確實(shí)沒有解決整合測試也稱 打包測試的@Suite.SuiteClasses方法,不過找到了別的批量執(zhí)行單元測試的方法,
在src/test/java 文件夾右鍵,run as -> junit test 一樣可以批量執(zhí)行!??!
springboot2.4降級到boot2.2.x
最近在做一個springcloud的整合項目,但是springcloud-alibaba的nacos只支持2.2.x版本,而項目開始也沒注意,直接用的2.4版本,所以這里記錄下降級踩下的坑。
這里直接把boot版本號改成2.2.6然后去啟動主啟動類會出現(xiàn)
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
以下提示:我的spring和我的boot不兼容,我boot版本太低,讓我改成2.3或者是2.4
***************************
APPLICATION FAILED TO START
***************************Description:
Your project setup is incompatible with our requirements due to following reasons:
- Spring Boot [2.2.6.RELEASE] is not compatible with this Spring Cloud release train
Action:Consider applying the following actions:
- Change Spring Boot version to one of the following versions [2.3.x, 2.4.x] .
You can find the latest Spring Boot versions here [https://spring.io/projects/spring-boot#learn].
If you want to learn more about the Spring Cloud Release train compatibility, you can visit this page [https://spring.io/projects/spring-cloud#overview] and check the [Release Trains] section.
If you want to disable this check, just set the property [spring.cloud.compatibility-verifier.enabled=false]Process finished with exit code 1
我這邊直接把springcloud版本一起降低改成H版本
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
</properties>
<dependencyManagement>
<dependencies>
<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>
再次啟動,發(fā)現(xiàn)可以了,好了不多bb了,我要去改接下去其他模塊了

以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
SpringBoot整合redis+lettuce的方法詳解
這篇文章主要介紹了SpringBoot整合redis+lettuce的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-08-08
idea中g(shù)it如何刪除commit提交的log信息
這篇文章主要介紹了idea中g(shù)it如何刪除commit提交的log信息問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-07-07
MyBatis基于pagehelper實(shí)現(xiàn)分頁原理及代碼實(shí)例
這篇文章主要介紹了MyBatis基于pagehelper實(shí)現(xiàn)分頁原理及代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-06-06
PowerJob LockService方法工作流程源碼解讀
這篇文章主要為大家介紹了PowerJob LockService方法工作流程源碼解讀,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2024-01-01
java+jdbc+mysql+socket搭建局域網(wǎng)聊天室
這篇文章主要為大家詳細(xì)介紹了java+jdbc+mysql+socket搭建局域網(wǎng)聊天室,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-01-01
Mybatis?TypeHandler接口及繼承關(guān)系示例解析
這篇文章主要為大家介紹了Mybatis?TypeHandler接口及繼承關(guān)系示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02
java:?無效的目標(biāo)發(fā)行版:?20問題解決辦法
這篇文章主要給大家介紹了關(guān)于java:?無效的目標(biāo)發(fā)行版:?20問題的解決辦法,出現(xiàn)這個問題大多數(shù)是因?yàn)樽约喊惭b的jdk版本和你在運(yùn)行項目時的所選的jdk版本不一致所導(dǎo)致的,需要的朋友可以參考下2024-03-03

