but was actually of type 'com.sun.proxy.$Proxy**'解决方法

由于项目使用了shiro安全框架,启动一直报错


在shiro中有这个配置

<!-- 开启Shiro注解 -->
	<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
		depends-on="lifecycleBeanPostProcessor">
	</bean>
	<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
		<property name="securityManager" ref="securityManager" />
	</bean>

	<!-- 安全管理器 -->
	<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
		<property name="realm" ref="myRealm" />
		<!-- 注入缓存管理器 -->
		<property name="cacheManager" ref="cacheManager" />
		<!-- 注入session管理器 -->
		<property name="sessionManager" ref="sessionManager" />
	</bean>
这是
DefaultAdvisorAutoProxyCreator 所使用代理器混乱的问题:需要在里面添加下面的一句话:
<property name="proxyTargetClass" value="true"/>


<!-- 开启Shiro注解 -->
	<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
		depends-on="lifecycleBeanPostProcessor">
		<property name="proxyTargetClass" value="true"/>
	</bean>
	<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
		<property name="securityManager" ref="securityManager" />
	</bean>

	<!-- 安全管理器 -->
	<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
		<property name="realm" ref="myRealm" />
		<!-- 注入缓存管理器 -->
		<property name="cacheManager" ref="cacheManager" />
		<!-- 注入session管理器 -->
		<property name="sessionManager" ref="sessionManager" />
	</bean>
重新启动,OK,启动成功

猜你喜欢

转载自blog.csdn.net/qq_38157516/article/details/80136908