解决Spring测试出现@EnableAsync annotation metadata was not injected

 Spring测试的时候,出现如下报错,非常奇怪
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.context.annotation.internalAsyncAnnotationProcessor’ defined in class path resource [org/springframework/scheduling/annotation/ProxyAsyncConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor]: Factory method ‘asyncAdvisor’ threw exception; nested exception is java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor]: Factory method ‘asyncAdvisor’ threw exception; nested exception is java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
… 43 more
Caused by: java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected
at org.springframework.util.Assert.notNull(Assert.java:201)
at org.springframework.scheduling.annotation.ProxyAsyncConfiguration.asyncAdvisor(ProxyAsyncConfiguration.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
… 44 more

解决Spring测试出现@EnableAsync annotation metadata was not injected_第1张图片
解决Spring测试出现@EnableAsync annotation metadata was not injected_第2张图片
 后来发现把配置类放在了根路径下,让配置类放在某包路径下就好了
修改前
解决Spring测试出现@EnableAsync annotation metadata was not injected_第3张图片
修改后
解决Spring测试出现@EnableAsync annotation metadata was not injected_第4张图片

你可能感兴趣的:(Spring,spring,java)