Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-07-10 13:45:09.842 ERROR 10752 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
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.autowireResource(CommonAnnotationBeanPostProcessor.java:526)
The following method did not exist:
org.springframework.beans.factory.config.AutowireCapableBeanFactory.resolveBeanByName(Ljava/lang/String;Lorg/springframework/beans/factory/config/DependencyDescriptor;)Ljava/lang/Object;
The method's class, org.springframework.beans.factory.config.AutowireCapableBeanFactory, is available from the following locations:
jar:file:/C:/Users/jason/.m2/repository/org/springframework/spring-beans/5.1.3.RELEASE/spring-beans-5.1.3.RELEASE.jar!/org/springframework/beans/factory/config/AutowireCapableBeanFactory.class
It was loaded from the following location:
file:/C:/Users/jason/.m2/repository/org/springframework/spring-beans/5.1.3.RELEASE/spring-beans-5.1.3.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.beans.factory.config.AutowireCapableBeanFactory
Process finished with exit code 1
以上是报错信息。
错误描述:在controller层引入Mapper接口用的@Resource在项目启动时报错。
报错信息如上,同样的情况用@Autowired就能正常使用。
百思不得其解研究了好久。。。
解决方法:后来在报错信息里找到了pom里对应的配置项,并且注释掉。
之后就成功了。
@Autowired和@Resource都能正常使用
关于@Autowired编译报错时,可以忽略,或者在接口上面加上@Component注解,如下: