日期:2014-05-19 浏览次数:20965 次
Error creating bean with name 'bookDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'sessionFactory' of bean class [org.dao.imp.BookDaoImp]: 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? Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'sessionFactory' of bean class [org.dao.imp.BookDaoImp]: 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?
<!-- 对dao进行依赖注入 -->
<bean id="bookDao" class="org.dao.imp.BookDaoImp">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!--对service进行依赖注入Dao -->
<bean id="bookService" class="org.service.imp.BookServiceImp">
<property name="bookDao" ref="bookDao"></property>
</bean>
<!-- 对action进行注入 -->
<bean id="bookAction" class="org.action.BookAction">
<property name="bookService" ref="bookService"></property>
</bean>
public class BookDaoImp extends HibernateDaoSupport implements BookDao{
public D101 selectBook2(String d10145) {
List list=this.getHibernateTemplate().find("from D101 where d10145=?",d10145);
D101 d101=null;
if(list.size()>0){
d101=(D101) list.get(0);
}
return d101;
}
}
public class BookServiceImp implements BookService{
private BookDao bookDao;
public BookDao getBookDao() {
return bookDao;
}
public void setBookDao(BookDao bookDao) {
this.bookDao = bookDao;
}
public D101 selectBook2(String d10145) {
return bookDao.selectBook2(d10145);
}
}
public class BookAction extends ActionSupport{
private D101 d101;
private BookService bookService;
public D101 getD101() {
return d101;
}
public void setD101(D101 d101) {
this.d101 = d101;
}
public BookService getBookService() {
return bookService;
}
public void setBookService(BookService bookService) {
this.bookService = bookService;
}
public String selectBook(){
D101 b=bookService.selectBook2(d101.getD10145());
if (b!=null) {
Map sess