简体   繁体   中英

Java spring portlet extends GenericPortlet how to autowire dependencies

I am using java - spring - portlet

I want to keep using my portlet as extend to GenericPortlet but i want to use spring dependency injections.

Currently i found the work around which is as follows instead i want to autoWire AccountsDao dependency. Can somebody help me out that how can i autowire when my portlet extends GenericPortlet and not @Controller

public class HelloPortlet extends GenericPortlet {

@ProcessAction(name = "searchAccount") 
    public void listAllAccounts(ActionRequest request, ActionResponse response) {

ApplicationContext springCtx = PortletApplicationContextUtils
                .getWebApplicationContext(getPortletContext());
        AccountsDao dao  = (AccountsDao)springCtx.getBean("accountsDao");
}

}

最后,我必须配置并启用基于spring的控制器来实现此目的,而不是扩展到GenericPortlet。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM