Java Bean属性';sessionFactory';不可写或具有无效的setter方法
我有一个错误:Java Bean属性';sessionFactory';不可写或具有无效的setter方法,java,spring,hibernate,Java,Spring,Hibernate,我有一个错误: bean类[com.aptech.mavenspringmvc.dao.StudentDAOImpl]的无效属性“sessionFactory”:bean属性“sessionFactory”不可写或具有无效的setter方法。setter的参数类型与getter的返回类型匹配吗? 文件DAO实现 @Repository public class StudentDAOImpl implements StudentDAO{ @Autowired public Sessio
bean类[com.aptech.mavenspringmvc.dao.StudentDAOImpl]的无效属性“sessionFactory”:bean属性“sessionFactory”不可写或具有无效的setter方法。setter的参数类型与getter的返回类型匹配吗?
文件DAO实现
@Repository
public class StudentDAOImpl implements StudentDAO{
@Autowired
public SessionFactory session;
文件道
@Service
public class StudentServiceImpl implements StudentService{
//@Autowired
public StudentDAO studao;
public void setStudao(StudentDAO studao) {
this.studao = studao;
}
public StudentDAO getStudao() {
return studao;
}
文件控制器
@Controller
public class StudentController {
// @Autowired
private StudentService stuSer;
在XML配置中,您正在设置studDaobean的sessionFactory属性
但是在您发布的代码中,该属性被命名为session。谢谢您的回答,但仍然无法处理此错误您在DaoImpl中是否有用于“session”属性的setter方法?
@Repository
public class StudentDAOImpl implements StudentDAO{
@Autowired
public SessionFactory sessionFactory;
....
public void setSessionFactory(SessionFactory sessionFactory){
this.sessionFactory = sessionFactory;
}
}