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

最近在做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包之后,问题解决了。

猜你喜欢

转载自blog.csdn.net/liuyunyihao/article/details/86483891