当前位置:首页>开发>正文

为什么我的spring@Autowired的字段为空 请教Spring注入得到的值为null

2023-06-05 13:27:27 互联网 未知 开发

 为什么我的spring@Autowired的字段为空 请教Spring注入得到的值为null

为什么我的spring@Autowired的字段为空

为什么我的spring@Autowired的字段为空
// dao
public class BaseDaoHibernateextends HibernateDaoSupport implements BaseDao { protected Class persistentClass @Autowired public void setSessionFactory0(SessionFactory sessionFactory) { super.setSessionFactory(sessionFactory) } @Repository("authorizeDao") public class AuthorizeDaoHibernate extends BaseDaoHibernate implements AuthorizeDao { private Criteria getAuthorizeCriteria(Authorize auth) { Criteria crit = getCriteria() Example example = Example.create(auth) example.enableLike(MatchMode.ANYWHERE) crit.add(example) if (auth.getDate_s() != null) { crit.add(Restrictions.ge("createDate", auth.getDate_s())) } if (auth.getDate_e() != null) { crit.add(Restrictions.le("createDate", auth.getDate_e())) } return crit } // service @Service("authorizeService") public class AuthorizeServiceImpl implements AuthorizeService { @Autowired private AuthorizeDao authorizeDao public Authorize getAuthorizeByAuthId(Long authId) { return authorizeDao.getById(authId) } public List findAll() { return authorizeDao.findAll() } //action @SuppressWarnings("serial") public class AdminAction extends AuthAction { private SiteBackGroudUser user private Long keyId private List auths private Page page @Autowired private SiteBackGroudUserService siteBackGroudUserService @Autowired private AuthorizeService authorizeService

请教Spring注入得到的值为null

从你的配置信息看出你有UserService的接口实现类那么
定义的userservice 的变量 userServiceImpl 和你UserService实现接口类

随便看看