@EnableAsync annotation metadata was not injected

2015年12月20日 20:06:54
  • 7570

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

  1. 警告: Exception encountered during context initialization - cancelling refresh attempt
  2. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalAsyncAnnotationProcessor' defined in org.springframework.scheduling.annotation.ProxyAsyncConfiguration: 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
  3. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
  4. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
  5. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014)
  6. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
  7. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
  8. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
  9. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  10. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
  11. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
  12. at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:220)
  13. at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:615)
  14. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465)
  15. at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
  16. at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
  17. at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
  18. at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:782)
  19. at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:424)
  20. at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:774)
  21. at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)
  22. at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
  23. at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
  24. at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
  25. at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
  26. at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
  27. at org.eclipse.jetty.server.Server.doStart(Server.java:282)
  28. at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
  29. at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedAdapter.start(JettyEmbeddedAdapter.java:67)
  30. at net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.launch(AbstractJettyLauncherMain.java:84)
  31. at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedLauncherMain.main(JettyEmbeddedLauncherMain.java:42)
  32. 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
  33. at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
  34. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
  35. ... 28 more
  36. Caused by: java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected
  37. at org.springframework.util.Assert.notNull(Assert.java:112)
  38. at org.springframework.scheduling.annotation.ProxyAsyncConfiguration.asyncAdvisor(ProxyAsyncConfiguration.java:45)
  39. at org.springframework.scheduling.annotation.ProxyAsyncConfiguration
    EnhancerBySpringCGLIBEnhancerBySpringCGLIB

    82eb591.CGLIB$asyncAdvisor$0(<generated>)

  40. at org.springframework.scheduling.annotation.ProxyAsyncConfiguration
    EnhancerBySpringCGLIBEnhancerBySpringCGLIB

    82eb591

    FastClassBySpringCGLIBFastClassBySpringCGLIB

    ed8c37b9.invoke(<generated>)

  41. at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
  42. at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
  43. at org.springframework.scheduling.annotation.ProxyAsyncConfiguration
    EnhancerBySpringCGLIBEnhancerBySpringCGLIB

    82eb591.asyncAdvisor(<generated>)

  44. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  45. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  46. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  47. at java.lang.reflect.Method.invoke(Method.java:606)
  48. at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
  49. ... 29 more
  50. 十二月 16, 2015 11:42:21 下午 org.springframework.web.context.ContextLoader initWebApplicationContext
  51. 严重: Context initialization failed
  52. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalAsyncAnnotationProcessor' defined in org.springframework.scheduling.annotation.ProxyAsyncConfiguration: 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
  53. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
  54. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
  55. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014)
  56. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
  57. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
  58. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
  59. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  60. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
  61. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
  62. at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:220)
  63. at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:615)
  64. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465)
  65. at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
  66. at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
  67. at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
  68. at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:782)
  69. at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:424)
  70. at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:774)
  71. at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)
  72. at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
  73. at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
  74. at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
  75. at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
  76. at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
  77. at org.eclipse.jetty.server.Server.doStart(Server.java:282)
  78. at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
  79. at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedAdapter.start(JettyEmbeddedAdapter.java:67)
  80. at net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.launch(AbstractJettyLauncherMain.java:84)
  81. at net.sourceforge.eclipsejetty.starter.embedded.JettyEmbeddedLauncherMain.main(JettyEmbeddedLauncherMain.java:42)
  82. 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
  83. at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
  84. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
  85. ... 28 more
  86. Caused by: java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected
  87. at org.springframework.util.Assert.notNull(Assert.java:112)
  88. at org.springframework.scheduling.annotation.ProxyAsyncConfiguration.asyncAdvisor(ProxyAsyncConfiguration.java:45)
  89. at org.springframework.scheduling.annotation.ProxyAsyncConfiguration
    EnhancerBySpringCGLIBEnhancerBySpringCGLIB

    82eb591.CGLIB$asyncAdvisor$0(<generated>)

  90. at org.springframework.scheduling.annotation.ProxyAsyncConfiguration
    EnhancerBySpringCGLIBEnhancerBySpringCGLIB

    82eb591

    FastClassBySpringCGLIBFastClassBySpringCGLIB

    ed8c37b9.invoke(<generated>)

  91. at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
  92. at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
  93. at org.springframework.scheduling.annotation.ProxyAsyncConfiguration
    EnhancerBySpringCGLIBEnhancerBySpringCGLIB

    82eb591.asyncAdvisor(<generated>)

  94. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  95. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  96. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  97. at java.lang.reflect.Method.invoke(Method.java:606)
  98. at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
  99. ... 29 more

错误原因:

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

改动前:

  1. <!-- 包扫描器 -->
  2. <context:component-scan base-package="*"/>

改动后(具体指定了要扫描的包):

  1. <!-- 包扫描器 -->
  2. <context:component-scan base-package="com.git.*"/>

@EnableAsync annotation metadata was not injected Spring容器启动后访问Servlet报错的更多相关文章

  1. @EnableAsync annotation metadata was not injected

    [问题描述] @EnableAsync annotation metadata was not injected spring配置初始化时候报错 nested exception is java.la ...

  2. Hive启动后show tables报错:Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

    错误详情: FAILED: HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive ...

  3. spring报nested exception is java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected错误

    http://www.oschina.net/question/1539472_159699

  4. Caused by: java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected

    需要注意的是ComponentScan 不能扫描 org.springframework 否则会报错,要扫描指定的package才行

  5. spring boot, 容器启动后执行某操作

    常有在spring容器启动后执行某些操作的需求,现做了一个demo的实现,做一下记录,也希望可以给需要的同学提供参考. 1.spring启动后,以新线程执行后续需要的操作,所以执行类实现Runnabl ...

  6. spring容器启动扩展

    我们可以在spring容器启动时添加自己的定制化初始化工作. 1)具体方法为:在web.xml中配置初始化属性contextInitializerClasses的值例如: <context-pa ...

  7. web容器启动后自动执行程序的几种方式比较

    1.       背景 1.1.       背景介绍 在web项目中我们有时会遇到这种需求,在web项目启动后需要开启线程去完成一些重要的工作,例如:往数据库中初始化一些数据,开启线程,初始化消息队 ...

  8. docker容器启动后添加端口映射

    DOCKER 给运行中的容器添加映射端口 方法1 1.获得容器IP 将container_name 换成实际环境中的容器名 docker inspect `container_name` | grep ...

  9. Bug集锦-Spring Cloud Feign调用其它接口报错

    问题描述 Spring Cloud Feign调用其它服务报错,错误提示如下:Failed to instantiate [java.util.List]: Specified class is an ...

随机推荐

  1. Docker生态会重蹈Hadoop的覆辙吗?

    从网上找到了这篇2016年中旬刷爆朋友圈的文章,没有找到作者和首发出处.两年多过去了,文中分析的很多不确定性都有了结论,里面不少分析思路.观点还是很不错的. Docker的兴起和Hadoop何其相似 ...

  2. 【转】VC中MessageBox与AfxMessageBox用法与区别

    原文网址:http://blog.csdn.net/holybin/article/details/28403109 一.MessageBox()用法 1.函数原型 Messagebox函数在Win3 ...

  3. wordpress上传文件,插件无法建立目录(根本原因解决)

    刚建立的wp网站经常遇到上传图片或者下载插件“无法建立目录”的问题,肯定是权限的问题,网上大部分解决方案都是把uploads或者 plugins权限手动改成777, 有一部分人成功了,有一部分没成功, ...

  4. 在同一服务器使用git分支建立线上 和 测试 项目

    分支分配文件夹后 sourcetree 创建分支与合并 https://blog.csdn.net/qq_34975710/article/details/74469068 线上分支master 测试 ...

  5. 3、MR开发入门

    1.预先准备2个文件file1.txt和file2.txt.文件内容为网页上摘下,不具有代表性,只为举例. file1.txt内容为: With this setup, whenever you ch ...

  6. htm标签的语意

    标签名 英文全拼 标签语意 div division 分割 span span 范围 ol ordered list 排序列表 ul unordered list 不排序列表 li list item ...

  7. da分布式算法

    参考学习<数字信号处理的FPGA实现> 思想如图: 在下半部分可以看到:是将N阶的数B bit,一位一位的移入LUT然后经过累加器.其中N个数需要2.^N次方长度的LUT,B bit表示需 ...

  8. <<杰克.韦尔奇自传>>

    <<杰克.韦尔奇自传>> 这本书号称是管理学十大经典名著,也是HR老师推荐的一本书.花了几个月时间断断续续拜读了这本书. GE是伟大的公司,杰克韦尔奇是伟大的CEO,这都毋庸置 ...

  9. 监控服务器所有用户的操作记录(测试只记录root用户)

    在linux系统的环境下,不管是root用户还是其它的用户只有登陆系统后用进入操作我们都可以通过命令history来查看历史记录,可是假如一台服务器多人登陆,一天因为某人误操作了删除了重要的数据.这时 ...

  10. CentOS7|Redhat7挂载NTFS格式磁盘

    //下载安装ntfs-3g_ntfsprogs.tgz软件包进行编译安装 tar -zxf ntfs-3g_ntfsprogs.tgz cd ntfs-3g_ntfsprogs ./configure ...