spring ioc问题,高手指教!
action中调用service层,service层中通过spring的依赖注入dao,但在调用的时候发现空指针异常,发现dao为空,请问原因在哪?哪位高手指教
配置如下:配置放两个配置文件中的:
applicationcontext-service.xml:
<bean id="userManager" class="org.opensource.service.impl.UserManagerImpl">
<property name="userDao" ref="userDao"/>
</bean>
applicationcontext-hibernate.xml:
<bean id="roleDao" class="org.opensource.dao.hibernate.RoleDaoHibernate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
public class RoleManagerImpl extends BaseManager implements RoleManager{
private RoleDao dao;
public Role getRole(String rolename) {
// TODO Auto-generated method stub
return dao.getRoleByName(rolename);//空指针异常处,dao为空
}
public void setRoleDao(RoleDao roleDao) {
// TODO Auto-generated method stub
this.dao=dao;
}
}