【发布时间】:2018-01-07 18:51:21
【问题描述】:
我已经完成了使用 @EnableGlobalMethodSecurity(prePostEnabled=true) 的 global-method-security 的配置,现在我需要为一些额外的方法应用 aspectj-autoproxy(@EnableAspectJAutoProxy(proxyTargetClass=true)),比如制作一个日志。但是我发现这两个相互冲突。我知道它们冲突的原因,但我不知道如何解决。所有这些配置都是基于java的。如果你知道解决方案,请告诉我。谢谢非常喜欢!
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled=true)
public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration{
}
---------------------------------------------------------------------------
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass=true)
@ComponentScan
public class AspectConfig {
@Bean
public ActionRecord record()
{
return new ActionRecord();
}
}
WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.event.internalEventListenerProcessor': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metaDataSourceAdvisor': Cannot resolve reference to bean 'methodSecurityMetadataSource' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodSecurityConfig': Unsatisfied dependency expressed through method 'setObjectPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: beike.visitorsystem.authority.controller [Xlint:invalidAbsoluteTypeName]
Jan 07, 2018 6:02:30 org.springframework.web.context.ContextLoader initWebApplicationContext
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.event.internalEventListenerProcessor': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metaDataSourceAdvisor': Cannot resolve reference to bean 'methodSecurityMetadataSource' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodSecurityConfig': Unsatisfied dependency expressed through method 'setObjectPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: beike.visitorsystem.authority.controller [Xlint:invalidAbsoluteTypeName]
【问题讨论】:
-
你能粘贴你得到的错误吗?
-
在设置构造函数参数时无法解析对 bean 'methodSecurityMetadataSource' 的引用;嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为 'methodSecurityConfig' 的 bean 时出错:通过方法 'setObjectPostProcessor' 参数 0 表达的依赖关系不满足;
-
我是 stackoverflow 的新手,我不知道如何粘贴有关此的更多详细信息...
-
您可以编辑您的原始帖子并将任何相关信息放在那里。越多,我们就越能为您提供帮助!
-
我已经编辑过了,这些信息有用吗?(非常感谢!)
标签: java spring security aspectj