创建名为“org.springframework.integration.internalMessagingAnnotationPostProcessor”的bean时出错

Posted

技术标签:

【中文标题】创建名为“org.springframework.integration.internalMessagingAnnotationPostProcessor”的bean时出错【英文标题】:Error creating bean with name 'org.springframework.integration.internalMessagingAnnotationPostProcessor' 【发布时间】:2020-07-16 03:04:53 【问题描述】:

我是 Spring Boot 新手,我的知识非常有限。我有一个适用于 spring boot 2.1 的应用程序,我想使用 spring boot 的最新版本,即 2.2.6。我做了应该做的事情,更改其他依赖版本,激活 bean 定义覆盖 ..etc 但是当我运行应用程序时,我得到了这个异常。任何帮助都将受到欢迎。

org.springframework.beans.factory.BeanCreationException: 错误 用名字创建bean 'org.springframework.integration.internalMessagingAnnotationPostProcessor': bean 实例化之前的 BeanPostProcessor 失败;嵌套的 例外是 org.springframework.beans.factory.BeanCreationException: 创建具有名称的 bean 时出错 'org.springframework.cache.annotation.ProxyCachingConfiguration': bean 实例化之前的 BeanPostProcessor 失败;嵌套的 例外是 org.springframework.beans.factory.BeanCreationException: 创建名为“metaDataSourceAdvisor”的 bean 时出错:无法解析 设置时引用 bean 'methodSecurityMetadataSource' 构造函数参数;嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建名称为“methodSecurityMetadataSource”的bean 类路径资源 [org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.class]: 通过工厂方法实例化 Bean 失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:失败 实例化 [org.springframework.security.access.method.MethodSecurityMetadataSource]: 工厂方法“methodSecurityMetadataSource”抛出异常;嵌套的 异常是java.lang.IllegalStateException: 在组成 所有全局方法配置,实际上没有注释支持 激活于 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:512) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:240) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:722) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 在 org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE] 在 com.smartest.connectedwell.service.addtostore.AddToStoreApplication.main(AddToStoreApplication.java:17) ~[classes/:na] 原因: org.springframework.beans.factory.BeanCreationException:错误 用名字创建bean 'org.springframework.cache.annotation.ProxyCachingConfiguration': bean 实例化之前的 BeanPostProcessor 失败;嵌套的 例外是 org.springframework.beans.factory.BeanCreationException: 创建名为“metaDataSourceAdvisor”的 bean 时出错:无法解析 设置时引用 bean 'methodSecurityMetadataSource' 构造函数参数;嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建名称为“methodSecurityMetadataSource”的bean 类路径资源 [org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.class]: 通过工厂方法实例化 Bean 失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:失败 实例化 [org.springframework.security.access.method.MethodSecurityMetadataSource]: 工厂方法“methodSecurityMetadataSource”抛出异常;嵌套的 异常是java.lang.IllegalStateException: 在组成 所有全局方法配置,实际上没有注释支持 激活于 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:512) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:409) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:91) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:109) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:92) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:101) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:251) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1141) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1114) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:506) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] ... 14个常用框架 省略原因: org.springframework.beans.factory.BeanCreationException:错误 创建名为“metaDataSourceAdvisor”的 bean:无法解析 设置时引用 bean 'methodSecurityMetadataSource' 构造函数参数;嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建名称为“methodSecurityMetadataSource”的bean 类路径资源 [org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.class]: 通过工厂方法实例化 Bean 失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:失败 实例化 [org.springframework.security.access.method.MethodSecurityMetadataSource]: 工厂方法“methodSecurityMetadataSource”抛出异常;嵌套的 异常是java.lang.IllegalStateException: 在组成 所有全局方法配置,实际上没有注释支持 激活于 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:691) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:91) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:109) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:92) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:101) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:251) ~[spring-aop-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1141) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1114) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:506) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] ... 35个常用框架 省略原因: org.springframework.beans.factory.BeanCreationException:错误 创建名称为“methodSecurityMetadataSource”的bean 类路径资源 [org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.class]: 通过工厂方法实例化 Bean 失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:失败 实例化 [org.springframework.security.access.method.MethodSecurityMetadataSource]: 工厂方法“methodSecurityMetadataSource”抛出异常;嵌套的 异常是java.lang.IllegalStateException: 在组成 所有全局方法配置,实际上没有注释支持 激活于 org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:484) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] ... 54个常用框架 省略原因: org.springframework.beans.BeanInstantiationException:失败 实例化 [org.springframework.security.access.method.MethodSecurityMetadataSource]: 工厂方法“methodSecurityMetadataSource”抛出异常;嵌套的 异常是java.lang.IllegalStateException: 在组成 所有全局方法配置,实际上没有注释支持 激活于 org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] 在 org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] ... 64个常用框架 省略引起:java.lang.IllegalStateException:在组合 在所有全局方法配置中,实际上没有注释支持 激活于 org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration.methodSecurityMetadataSource(GlobalMethodSecurityConfiguration.java:371) ~[spring-security-config-5.2.2.RELEASE.jar:5.2.2.RELEASE] 在 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 方法)~[na:na] 在 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] 在 java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] 在 java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na] 在 org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE] ... 65个常用框架 省略

【问题讨论】:

【参考方案1】:

在以前的版本中,可以使用 null MethodSecurityMetadataSource,但现在他们添加了 this check,如果您没有启用至少一个方法安全元数据源,它们会抛出您得到的异常 ("在所有全局方法配置的组合中,实际上没有激活注释支持”)。当我从 spring 5.0.7 更新到 5.1.5 时,这发生在我身上。这是 the issue 讨论此更改的地方

要修复它,请在 @EnableGlobalMethodSecurity 注释属性中启用元数据源之一,或者,如果您像我一样使用某种 GlobalMethodSecurityConfiguration,请确保方法 customMethodSecurityMetadataSource 返回非空

【讨论】:

以上是关于创建名为“org.springframework.integration.internalMessagingAnnotationPostProcessor”的bean时出错的主要内容,如果未能解决你的问题,请参考以下文章

创建名为 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0 的 bean 时出

创建名为“org.springframework.integration.internalMessagingAnnotationPostProcessor”的bean时出错

org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为“entityManagerFactory”的bean时出错

org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为“batchConfiguration”的bean时出错

org.springframework.beans.factory.BeanCurrentlyInCreationException:创建名为“sessionFactory”的bean时出错

IntelijIDEA:创建名为“org.springframework.transaction.config.internalTransactionAdvisor”的bean时出错