关于spring4与hibernate4注入问题,求大神!!!!!!!
spring配置如下
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="config" value="classpath:hibernate.cfg.xml"/>
</bean>
<bean id="userDao" class="com.ssh.dao.UserDao">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
UserDao类中也有sessionFactory的setter和getter
测试方法:
BeanFactory beanFactory=new ClassPathXmlApplicationContext("beans.xml");
UserDao userDao=beanFactory.getBean("userDao", UserDao.class);
System.out.println(userDao.select("jack", "123"));
报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [beans.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'config' of bean class [org.springframework.orm.hibernate4.LocalSessionFactoryBean]: Bean property 'config' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
这是什么问题,还请大神告知!!
[解决办法]
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
[解决办法]