使用spring自动装配后,怎么样使用new而里面装配的属性不报空指针
使用spring自动装配后,怎么样使用new而里面装配的属性不报空指针;
如:
public class PeopleMgmtImpl extends BaseMgmt implements PeopleMgmt{
@Autowired
private PeopleDAO peopleDAO;
public void setPeopleDAO(PeopleDAO peopleDAO){
this.peopleDAO = peopleDAO;
}
如果我在其他地方new了PeopleMgmtImpl ,peopleDAO会报空指针;
有没有好的办法可以解决。不要说peopleDAO也用new,有没有其他方法