[英]Creating a session-scoped proxy for a bean
导致异常的这种配置可能是什么问题?
java.lang.IllegalStateException: Cannot create scoped proxy for bean 'scopedTarget.testProxy': Target type could not be determined at the time of proxy creation.
<bean id="test" class="com.testsession.Test" scope="prototype" />
<bean id="testProxy" class="org.springframework.aop.framework.ProxyFactoryBean" scope="session">
<property name="target" ref="test" />
<property name="proxyInterfaces"><value>com.testsession.TestIface</value></property>
<aop:scoped-proxy/>
</bean>
会话范围的mvc控制器请求testProxy
bean。 该目标类型不是在proxyInterfaces
属性中指定的吗?
您在这里混淆了您的概念-您可以使用aop:scoped-proxy
或为显式ProxyFactoryBean
提供适当的设置,而不能同时提供两者。
要使用aop:scoped-proxy
:
<bean id="testProxy" class="com.testsession.Test" scope="session">
<aop:scoped-proxy />
</bean>
要显式配置代理bean:
<bean id="test" class="com.testsession.Test" scope="session" />
<bean id="testProxy" class="org.springframework.aop.scope.ScopedProxyFactoryBean">
<property name="targetBeanName" value="test" />
</bean>
注意,代理是使用目标bean 名称配置的,而不是对实际目标bean的引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.