2016-04-22 77 views
1

我有1錯誤:Bean屬性 'SessionFactory的' 不可寫無效或者和setter方法

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

文件DAO實現

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

文件DAO

@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; 

回答

1
@Repository 
public class StudentDAOImpl implements StudentDAO{ 

@Autowired 
public SessionFactory sessionFactory; 
.... 

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

感謝您的回答,但仍然沒有與此錯誤 –

+0

更新我的答案 – Helios

0

在XML配置,您要設置SessionFactory的studDao bean的屬性。

但是,該物業在您發佈的代碼中被命名爲會話

+0

感謝您的回答,但仍然無法正常工作 –

+0

您對DaoImpl中的「session」屬性有setter方法嗎? –

+0

好的非常感謝你 –

相關問題