pom中的junit依赖的<scope>设置为了test → maven项目的test目录隐藏了 → 运行时报错org.junit没发现;;;顺带介绍下【maven中的scope属性】;

这个错误时在OA系统六:前期准备四:整合FreeMarker;顺带设置下logback.xml;发布项目时遇到的。

目录

报错情况描述:

报错解决方案:

附加:maven中的scope属性


报错情况描述:

pom中的junit依赖的<scope>设置为了test:

然后,不知什么时候,test目录就隐藏了(搜索的话test目录还是在的,只是在工程结构上没有显示test目录):

即,在显示上java目录是直接隶属于src目录的。。。但是,搜索的话,test目录还是在的。

然后,无论是运行MyBatisUtilsTestor类,还是发布项目(这两种情况报的错一样),都会提示报错,在build的阶段就报错了,具体内容就是(PS:这个错误不能复现了~~~~):

【org.junit没发现】;;;找不到MyBatisUtils这之类的。

 

报错解决方案:

注释掉了<scope>test</scope>

<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.2.6.RELEASE</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>5.6.2</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.6.2</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.6.2</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-params --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-params</artifactId> <version>5.6.2</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-commons --> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-commons</artifactId> <version>1.6.2</version> </dependency> <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-engine --> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-engine</artifactId> <version>1.6.2</version> <scope>test</scope> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.12.3</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>compile</scope> </dependency> </dependencies>这是我的maven依赖,怎么将junit4 变成junit5
最新发布
08-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值