Hennessy Hade Hennessy Hade - 7 months ago 8
Java Question

Bean property 'sessionFactory' is not writable or has an invalid setter method

I have 1 error:

Invalid property 'sessionFactory' of bean class [com.aptech.mavenspringmvc.dao.StudentDAOImpl]: Bean property 'sessionFactory' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?


enter image description here

enter image description here

File DAO implement

@Repository
public class StudentDAOImpl implements StudentDAO{
@Autowired
public SessionFactory session;


File DAO

@Service
public class StudentServiceImpl implements StudentService{

//@Autowired
public StudentDAO studao;

public void setStudao(StudentDAO studao) {
this.studao = studao;
}

public StudentDAO getStudao() {
return studao;
}


File controller

@Controller
public class StudentController {
// @Autowired
private StudentService stuSer;

Answer
@Repository
public class StudentDAOImpl implements StudentDAO{

 @Autowired
 public SessionFactory sessionFactory;
 ....

 public void setSessionFactory(SessionFactory sessionFactory){
     this.sessionFactory = sessionFactory;
  }
}
Comments