之前在使用springboot开发系统的时候,用到了@Resouse的注解,在IDEA运行时没有发生任何异常,但是打包部署的时候就报jar包冲突。
09:07:51.234 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter - [report,40] -
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.<init>(CommonAnnotationBeanPostProcessor.java:664)
The following method did not exist:
'java.lang.String javax.annotation.Resource.lookup()'
The method's class, javax.annotation.Resource, is available from the following locations:
jar:file:/C:/vic/vic-admin.jar!/BOOT-INF/lib/jsr250-api-1.0.jar!/javax/annotation/Resource.class
jar:file:/C:/vic/vic-admin.jar!/BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar!/javax/annotation/Resource.class
The class hierarchy was loaded from the following locations:
javax.annotation.Resource: jar:file:/C:/vic/vic-admin.jar!/BOOT-INF/lib/jsr250-api-1.0.jar!/
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.annotation.Resource
原因:
jsr250-api-1.0.jar和jakarta.annotation-api-1.3.5.jar重复
解决:
在Maven的pom里引入
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
这么做的目的是叫系统自动引入最新的jar包