gpt4 book ai didi

java - Spring 全局方法安全性和 Aspectj

转载 作者:行者123 更新时间:2023-12-02 11:46:55 24 4
gpt4 key购买 nike

我已经完成了使用@EnableGlobalMethodSecurity(prePostEnabled=true)的全局方法安全性的配置,现在我需要应用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]

最佳答案

如果要在包中包含所有类,则需要在 AspectJ 配置文件中指定以下内容:beike.visitorsystem.authority.controller.*

否则,您可以只指定beike.visitorsystem.authority.controller.AuthorityController

关于java - Spring 全局方法安全性和 Aspectj,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48136015/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com