I used to have the following bean defined in XML (it worked!):
<bean id="session" class="mrpomario.springcore.bean_scopes.beans.SessionBean" scope="session">
<aop:scoped-proxy/>
</bean>
Now that I try to accomplish the same configuration through Java:
@Bean
@Scope("session")
@ScopedProxy
public SessionBean session() {
return new SessionBean();
}
I get the following error…
java.lang.IllegalStateException: No Scope registered for scope 'session'
…when I invoke session() as the argument of a setter in another bean.
Why does that happen and how do I solve it?
@ScopedProxyisn’t part of Spring’s Java configuraion. The solution is in the reference manual – useproxyModeof@Scopeannotation: