开发者

Using Spring managed DAO without controller?

开发者 https://www.devze.com 2022-12-12 06:55 出处:网络
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

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) 
0

精彩评论

暂无评论...
验证码 换一张
取 消