I'm trying to get my Portlets work with some DAO Objects which I configured as spring beans. I've included an application.xml to my WEB-INF, added it to my web.xml, configured hibernater support, a datasource. Everything seems fine, after deployment I see the context loaded message from spring. Now I'm trying to get one dao 开发者_如何学Pythonobject injected in my regular portlet (extends GenericPortlet) with the
[at]Autowired
Annonation. But the object is still null. Isn't it possible to use spring managed DAO objects without a regular spring mvc controller?
Thanks for reading
The classes that the DAO is to be injected into must be also inside ths spring context.
You can either take a look at this, or get the DAO by accessing the ApplicationContext
, rather than have the beans injected. The ApplicationContext can be obtained with:
PortletApplicationContextUtils.getRequiredWebApplicationContext(portletContext)
精彩评论