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 ==============异常结束=============
解决方法:
重新配置shiro的配置文件:
<!-- 开启Shiro注解 --> <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"> <property name="proxyTargetClass" value="true"/> </bean>
即可解决