首页 > 其他分享 >SpringSecurity集成启动报 In the composition of all global method configuration, no annotation support was

SpringSecurity集成启动报 In the composition of all global method configuration, no annotation support was

时间:2023-05-30 10:46:26浏览次数:36  
标签:11 5.2 java support global springframework beans RELEASE configuration

一.异常内容

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodSecurityMetadataSource' defined in class path resource [org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.access.method.MethodSecurityMetadataSource]: Factory method 'methodSecurityMetadataSource' threw exception; nested exception is java.lang.IllegalStateException: In the composition of all global method configuration, no annotation support was actually activated
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:483) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	... 36 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.access.method.MethodSecurityMetadataSource]: Factory method 'methodSecurityMetadataSource' threw exception; nested exception is java.lang.IllegalStateException: In the composition of all global method configuration, no annotation support was actually activated
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	... 46 common frames omitted
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.5.RELEASE.jar:5.3.5.RELEASE]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_361]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_361]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_361]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_361]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
	... 47 common frames omitted


进程已结束,退出代码1


二.导致原因

启动类注解

@EnableGlobalMethodSecurity

未开启基于方法的安全认证机制

三.解决方法

将注解的prePostEnabled设置未true

@EnableGlobalMethodSecurity(prePostEnabled=true)

开启基于方法的安全认证机制,也就是说在web层的controller启用注解机制的安全确认

只有加了@EnableGlobalMethodSecurity(prePostEnabled = true) 那么在接口上使用的 @PreAuthorize注解才会生效

@PreAuthorize("hasAuthority('bnt.sysRole.list')")

标签:11,5.2,java,support,global,springframework,beans,RELEASE,configuration
From: https://www.cnblogs.com/forever0406/p/17442578.html

相关文章

  • java.lang.UnsupportedOperationException
    错误的查询返回格式//dao层Listquery_T_JS_DHGL_XMLGJ(Map<String,String>queryParams);正确的的查询返回格式ArrayList<Map>query_T_JS_DHGL_XMLGJ(Map<String,String>queryParams);知识点:使用asList方法继承的父类的add和remove,只会抛出UnsupportedOper......
  • 银联notifyurl报错302重定向的问题排查,太奇怪了!AspxAutoDetectCookieSupport=1
    用银联的notifyurl接收通知,某一天突然通知没有了,日志里直接没有,就和银联的人一起查,发现错误302重定向。这个notifyurl用浏览器可以正常打开。但是发现打开后会自动追加一段:AspxAutoDetectCookieSupport=1。于是搜,最终发现问题如下图:在会话状态里cookie模式改成了自动检测,导致iis......
  • LockSupport与线程中断
    1LockSupport是什么LockSupport是用来创建锁和其他同步类的基本阻塞原语。park方法可以阻塞线程,unpark方法可以唤醒线程。与object的wait和notify不同的是,不需要synchonized的限制,没有先后顺序的限制。2线程中断线程不应该被其他线程中断,应该自己中断。线程的三个中断方法......
  • 动态路由 出现 for supported dynamic import formats. If this is intended to be
    forsupporteddynamicimportformats.Ifthisisintendedtobeleftas-is,youcanusethe/*@vite-ignore*/commentinsidetheimport()calltosuppressthiswarning.Plugin:vite:import-analysis如果不是vite,用以前的webpack,只需要()=>import(‘XXX’)只能成......
  • Firms sign investment deals worth $8.6b at Invest Beijing Global Summit
    Beijingwillcontinuetobeanattractiveinvestmentdestinationforforeigninvestors,asthecityisattheforefrontoftechnologicalinnovation,hasasoundbusinessenvironment,andmakesgreatereffortsindrivingreformandopening-up,saidexecuti......
  • netcore-configuration
    整个流程整理下。这种简单的Add可以运行。1先创建ConfigurationSource继承FileConfigurtaionSource1)ConfigurationBuilder.Add(Source);2)Builder()->IConfigurationProviderBuild(IConfigurationBuilderbuilder);产生Provider对象。加到ConfigurationRoot中。2......
  • jmeter之JDBC Connection Configuration 请求
    1、下载mysqljdbc驱动包(注:驱动包的版本一定要与你数据库的版本匹配,驱动版本低于mysql版本有可能会导致连接失败报错)我这里下载的是mysql-connector-j-8.0.33.jar下载完后,将jira包放在D:\jmeter\apache-jmeter-5.2.1\lib目录下,这样就jmeter中就有驱动了,重启jmeter  2.线程......
  • How to fix CMake error Could not find a package configuration file provided by
    CMakeErrorat/usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:117(find_package):Couldnotfindapackageconfigurationfileprovidedby"boost_filesystem"(requestedversion1.71.0)withanyofthefollowingnames:boos......
  • Spring6 探析之@Configuration 注解
    Spring6探析之@Configuration注解介绍@Configuration注解大家都不陌生,该注解有以下特点必须在类上使用能够将被注解的类加载到IOC容器里能够将类中被@Bean注解标记的方法加载到IOC容器里@Configuration有一些参数,其中最值得关注的是proxyBeanMethods,该参数值默认为tr......
  • 四、JUC-LockSupport与线程中断
    一、线程中断机制1、概述一个线程不应该由其他线程来强制中断或停止,而是应该由线程自己自行停止,所以,Thread.stop、Thread.suspend、Thread.resume都已经被废弃了在Java中没有办法立即停止一条线程,然而停止线程却显得尤为重要,如取消一个耗时操作。因此,Java提供了一种用于......