SpringSecurity集成啟動報 In the composition of all global method configuration, no annotation support was actually activated 異常


 

異常內容:

Caused by: java.lang.IllegalStateException: In the composition of all global method configuration, no annotation support was actually activated
    at org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration.methodSecurityMetadataSource(GlobalMethodSecurityConfiguration.java:373) ~[spring-security-config-5.3.3.RELEASE.jar:5.3.3.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_242]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_242]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_242]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_242]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]

 

導致的原因是 

@EnableGlobalMethodSecurity注解 prePostEnabled 屬性,是否開啟 PreAuthory 注解功能,類似的還有其他注解,Secured注解等等,這些注解的默認值都是false,也就是不啟用

 

 

 

解決方法就是配置以下就可以了:

@EnableGlobalMethodSecurity(prePostEnabled = true)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM