java.lang.ClassNotFoundException: org.junit.Before

文章详细介绍了在使用Spring4版本时遇到的JUnit依赖导致的类加载错误问题,并提供了将pom.xml中scope=test的依赖项删除的解决方案,以避免在启动服务时出现ClassNotFoundException。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、真是郁闷啊。明明已经添加了junit的依赖但是启动服务的时候老是报错

2015-01-24 16:00:22 [org.springframework.core.type.classreading.AnnotationAttributesReadingVisitor]-[DEBUG] Failed to class-load type while reading annotation metadata. This is a non-fatal error, but certain annotation metadata may be unavailable.

java.lang.ClassNotFoundException: org.junit.BeforeClass

 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)

 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)

 at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:180)

 at org.springframework.asm.ClassReader.readAnnotationValues(ClassReader.java:1491)

 at org.springframework.asm.ClassReader.readMethod(ClassReader.java:909)

解决方案是将pom.xml的<scope>test</scope> 删除:

<dependency>

        <groupId>junit</groupId>

        <artifactId>junit</artifactId>

        <version>4.12</version>

        <scope>test</scope>

 </dependency>

之前用的是spring3*版本也没出现这个问题。到了spring4*就出这个问题了。



转载于:https://my.oschina.net/u/260244/blog/371365

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值