@EnableAsync annotation metadata was not injected

xiaoxiao2021-02-28  57

在初始化spring事务部分碰到该错误, 详细错误信息如下:

Caused by: java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected       at org.springframework.util.Assert.notNull(Assert.java:112)       at org.springframework.scheduling.annotation.ProxyAsyncConfiguration.asyncAdvisor(ProxyAsyncConfiguration.java:45)       at org.springframework.scheduling.annotation.ProxyAsyncConfiguration 错误原因:

在spring的配置文件applicationContext.xml中, 配置包扫描器时, 使用了*, 想扫描所有的包; 而这种方式有可能扫描到spring自带的包, 造成错误(自我理解, 不对的话求教育)

改动前:

[html]  view plain  copy <!-- 包扫描器 -->   <context:component-scan base-package="*"/>   改动后(具体指定了要扫描的包):

[html]  view plain  copy <!-- 包扫描器 -->   <context:component-scan base-package="com.git.*"/>  
转载请注明原文地址: https://www.6miu.com/read-78557.html

最新回复(0)