Java 弹簧靴&x2B;AspectJ不工作的Spring安全性
我正在尝试用AspectJ建议模式配置spring全局方法安全性,这样我就可以在所有Java 弹簧靴&x2B;AspectJ不工作的Spring安全性,java,spring,spring-security,spring-boot,aspectj,Java,Spring,Spring Security,Spring Boot,Aspectj,我正在尝试用AspectJ建议模式配置spring全局方法安全性,这样我就可以在所有@Configurable注释类中使用@PreAuthorize注释。这是我的java配置: @Configuration @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true, mode = AdviceMode.ASPECTJ) public class MethodSecurityConfig extends Glo
@Configurable
注释类中使用@PreAuthorize
注释。这是我的java配置:
@Configuration
@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true, mode = AdviceMode.ASPECTJ)
public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration
以及:
这是我的@可配置
类:
@Configurable
public class Entity {
@PreAuthorize("hasPermission(this, 'publish')")
public void method() { }
}
我还添加了spring安全方面作为依赖项。从AspectJ日志中,我可以清楚地看到Spring安全相关方面应用于我的@Configurable
类,但是,一旦我创建这些类的实例,我就会得到以下异常:
Post-processor tried to replace bean instance of type [com.example.Entity] with (proxy) object of type [com.sun.proxy.$Proxy130] - not supported for aspect-configured classes!
我使用的是spring启动版本1.2.1,因此spring安全版本是3.2.5。这似乎是这里讨论的bug:
但是这个错误不应该影响我的spring security版本。。。这个问题有解决办法吗?好的,我已经解决了。这是spring boot的SecurityAutoConfiguration类的问题。我不得不将其从自动配置中排除,并手动配置spring安全性-这没什么大不了的,但无论如何…您能否详细说明一下您是如何禁用自动配置和手动设置bean的?我试图让它自己工作,但在SpringBoot和AspectJ中遇到了相同的错误消息。
Post-processor tried to replace bean instance of type [com.example.Entity] with (proxy) object of type [com.sun.proxy.$Proxy130] - not supported for aspect-configured classes!