【shiro】报错: If the controller requires proxying (e.g. due to @Transactional), please use class-based proxying.

简介: spring整合shiro,项目报如下错误: 1 ==============异常开始============= 2 java.lang.IllegalStateException: The mapped controller method class 'com.

spring整合shiro,项目报如下错误:

 1 ==============异常开始=============
 2 java.lang.IllegalStateException: The mapped controller method class 'com.agen.controller.CorlibController' is not an instance of the actual controller bean instance 'com.sun.proxy.$Proxy45'. If the controller requires proxying (e.g. due to @Transactional), please use class-based proxying.
 3 HandlerMethod details: 
 4 Controller [com.sun.proxy.$Proxy45]
 5 Method [public java.lang.String com.agen.controller.CorlibController.queryAll(java.lang.String,java.lang.String,org.springframework.web.servlet.mvc.support.RedirectAttributes)]
 6 Resolved arguments: 
 7 [0] [type=java.lang.String] [value=corlib]
 8 [1] [null] 
 9 [2] [type=org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap] [value={}]
10 
11     at org.springframework.web.method.support.InvocableHandlerMethod.assertTargetBean(InvocableHandlerMethod.java:261)
12     at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:224)
13     at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
14     at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
15     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
16     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
17     at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
18     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
19     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
20     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
21     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
22     at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
23     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
24     at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
25     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
26     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
27     at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
28     at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
29     at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
30     at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
31     at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
32     at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
33     at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
34     at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
35     at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
36     at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
37     at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
38     at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
39     at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
40     at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
41     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
42     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
43     at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)
44     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
45     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
46     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
47     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
48     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
49     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
50     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
51     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
52     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
53     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
54     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
55     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
56     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
57     at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
58     at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617)
59     at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1778)
60     at java.lang.Thread.run(Thread.java:745)
61 ==============异常结束=============
View Code

 

解决方法:

重新配置shiro的配置文件:

<!-- 开启Shiro注解 -->
    <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor">
        <property name="proxyTargetClass" value="true"/> 
    </bean>  

即可解决

相关文章
|
NoSQL Redis
Consider defining a bean of type ‘com.bsj.system.service.RedisService‘ in your configuration
Consider defining a bean of type ‘com.bsj.system.service.RedisService‘ in your configuration
570 0
shiro学习之错误 No realms have been configured! One or more realms must be present to execute an authori
shiro学习之错误 No realms have been configured! One or more realms must be present to execute an authori
|
3月前
|
Java Nacos 微服务
JSR-330 ‘javax.inject.Inject‘ annotation found and supported for autowiring
这篇文章讨论了在Spring Boot项目中遇到的JSR-330 `javax.inject.Inject`注解相关问题,以及如何解决因版本不兼容导致服务注册失败的问题。
|
3月前
Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons
Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not allowed while singletons
101 3
IDEA添加Swagger2:Parameter 0 of method linkDiscoverers in org. springframework hateoas.config.Hateoasconfiguration required a single bean, but 15 were found:
IDEA添加Swagger2:Parameter 0 of method linkDiscoverers in org. springframework hateoas.config.Hateoasconfiguration required a single bean, but 15 were found
|
Java 数据库连接 Redis
Bean method ‘redisConnectionFactory‘ not loaded because @ConditionalOnClass did not find required c
Bean method ‘redisConnectionFactory‘ not loaded because @ConditionalOnClass did not find required c
102 0
|
Java
ApplicationContext is unlikely to start due to a @ComponentScan of the default package
解决办法: 1、一般发出这个警告的原因是你把启动类直接放在的src目录下面。 2、你需要在src目录下面再建一个包,然后把启动类放到下面。 3、或者你错将启动类放到java文件中了,与项目包成了同级文件,你只需要将启动类放到项目包里就可以。
88 0
|
Java Apache Spring
解决required a single bean, but 2 were found问题
背景:springboot整合shiro中自定义Realm时出现 错误描述 Parameter 0 of method getDefaultWebSecurityManager in cn.ken.springboot_shiro.config.ShiroConfig required a single bean, but 2 were foun
|
druid
A bean with that name has already been defined in class path resource and overriding is disabled.
A bean with that name has already been defined in class path resource and overriding is disabled.
218 0
|
Nacos
Nacos报错:Error creating bean with name ‘authFilterRegistration‘ defined in class path resource
Nacos报错:Error creating bean with name ‘authFilterRegistration‘ defined in class path resource
482 0