我有一个带有JSF 2.2,Spring 4,ang Hibernate Integration的Web应用程序。当我尝试在ManagedBean中使用ManagedProperty注入Spring Service时,我有一个Nullpointer异常:
@ManagedBean
@ViewScoped
public class SuperAdminNuevasAppBean {
@ManagedProperty(value = "#{appService}")
private AppService appService;
//Code
}
AppService是一个界面:
public interface AppService {
public abstract void persist(App transientInstance);
public abstract void remove(App persistentInstance);
public abstract App merge(App detachedInstance);
//
}
这是实施:
@Service
public class AppServiceImpl implements AppService {
@Autowired
private AppDAO appDAO;
@Autowired
private EdificioDAO edificioDAO;
@Override
@Transactional
public void persist(App transientInstance) {
// TODO Auto-generated method stub
appDAO.persist(transientInstance);
}
//More code...
如果我把
@ManagedProperty(value = "#{appServiceImpl}")
private AppService appService;
一切正常。 我有getter和setter,faces-config中的org.springframework.web.jsf.el.SpringBeanFacesELResolver,web.xml中的org.springframework.web.context.ContextLoaderListener和org.springframework.web.context.request.RequestContextListener 。这是正确的行为吗?