java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.isInJavaLangAnnotat

本文详细解析了在使用Spring框架时遇到的启动错误,错误原因为引用了冲突的jar包,具体是org.springframework.core-3.1.3.RELEASE.jar和spring-core-4.1.7.RELEASE.jar之间的冲突,导致NoSuchMethodError异常。通过移除冲突的jar包解决了问题。

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

最近在做spring框架练习时,遇到启动程序报错,摘取部分片段如下:

Caused by: java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.isInJavaLangAnnotationPackage(Ljava/lang/annotation/Annotation;)Z
	at org.springframework.core.annotation.AnnotatedElementUtils.doProcess(AnnotatedElementUtils.java:209)
	at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:162)
	... 60 more
一月 14, 2019 8:49:59 下午 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet /firstweb threw load() exception
java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.isInJavaLangAnnotationPackage(Ljava/lang/annotation/Annotation;)Z
	at org.springframework.core.annotation.AnnotatedElementUtils.doProcess(AnnotatedElementUtils.java:209)
	at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:162)
	at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:91)
	at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:85)
	at org.springframework.transaction.annotation.SpringTransactionAnnotationParser.parseTransactionAnnotation(SpringTransactionAnnotationParser.java:42)
	at org.springframework.transaction.annotation.AnnotationTransactionAttributeSource.determineTransactionAttribute(AnnotationTransactionAttributeSource.java:154)
	at org.springframework.transaction.annotation.AnnotationTransactionAttributeSource.findTransactionAttribute(AnnotationTransactionAttributeSource.java:133)

找了半天原因,最后发现是引用的包冲突导致,同时引用了org.springframework.core-3.1.3.RELEASE.jar和spring-core-4.1.7.RELEASE.jar,起了冲突。两个jar包中都有AnnotationUtils.class文件,但org.springframework.core-3.1.3.RELEASE.jar包中的AnnotationUtils.class里没有isInJavaLangAnnotationPackage方法,而启动时程序时起作用的恰恰是org.springframework.core-3.1.3.RELEASE.jar包中的AnnotationUtils.class文件,所以就报错了。去掉冲突的jar包之后,问题解决了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值