Reputation: 645
I have a web controller which I configure in the controller-config.xml using
<mvc:annotation-driven />
<context:annotation-config />
<context:component-scan base-package="com.ecommerce.web.controller" />
The controller has the @Controller annotation like below.
@Controller
public class HomeController
I have included the @Autowired annotation on the dependencies, but when I first start up the application I am unable to set any properties on the wired objects.
For example, I have a storeProfile object which when in debug mode I see has multiple properties set as it should. But, when I try to set one of the storeProfile properties on an @Autowried bean it is still null or empty string!?
If you look at the attached images it shows that after I step past the line this.storeProfileContext.setStoreProfile(storeProf ile) the debugger still shows the storeProfile property as null
Actually, there are a couple dependencies which look like they are created (they are not null and the application functions), but I am unable to set anything on these objects.
I asked the same question on the Spring forums too - hoping to get this figured out.
Thanks so much!
Upvotes: 0
Views: 276
Reputation: 49935
That is because you are looking at the fields of the proxy, which gets created when you have <aop:scoped-proxy/>
, if you invoke your getter for the set values, you should see the correct values retrieved from the proxied object.
Upvotes: 1
Reputation: 17774
The instances you are examining are CGLIB proxies.
CGLIB subclasses your beans, delegating all method invocations to the target beans.
So the fields of the super classes are still present but not used.
Upvotes: 0