亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Spring3.2.0整合hibernate3 sessionFatory無法注入

Spring3.2.0整合hibernate3 sessionFatory無法注入

FloatingShuYin 2016-10-11 22:00:24
控制臺報錯:Bean property 'sessionFatory' is not writable or has an invalid setter method. Did you mean 'sessionFactory'?DAO層類繼承?HibernateDaoSupport類無法通過this.getHibernateTemplate 獲取sessionthis.語法錯誤強行運行?控制臺報錯:ERROR - Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productDao' defined in class path resource [spring.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'sessionFatory' of bean class [cn.star.ssh.dao.ProductDao]: Bean property 'sessionFatory' is not writable or has an invalid setter method. Did you mean 'sessionFactory'?DAO層代碼:public class ProductDao extends HibernateDaoSupport { /** * DAO中保存商品的方法 * @param product */ public static void save(Product product) { ? ? ? ?System.out.println("DAO中的save方法執行了..."); ? ? ? ?this.getHibernateTemplate.save(product); }}Spring 配置:<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsdhttp://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsdhttp://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsdhttp://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd"> <!-- 引入外部的屬性文件 --> <context:property-placeholder location="classpath:jdbc.properties"/> <!-- 配置c3p0連接池 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driverClass}"/> <property name="jdbcUrl" value="${jdbc.url}"/> <property name="user" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean> <!-- 配置Hibernate的相關屬性 --> <bean id="sessionFatory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 配置Hibernate的屬性 --> <property name="hibernateProperties"> ? <props> <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> </props> </property> <!-- 加載Hibernate中的映射文件 --> <property name="mappingResources"> <list> <value>cn/star/ssh/entity/Product.hbm.xml</value> </list> </property> <!-- 注入連接池 --> <property name="dataSource" ref="dataSource"></property> </bean> <!-- 配置DAO的類 --> <bean id="productDao" class="cn.star.ssh.dao.ProductDao"> <property name="sessionFatory" ref="sessionFatory"></property> </bean> <!-- 配置Action類 --> <bean id="productAction" class="cn.star.ssh.action.ProductAction" scope="prototype"> <property name="productService" ref="productService"></property> </bean> <!-- 配置業務層的類 --> <bean id="productService" class="cn.star.ssh.service.ProductService"> <property name="productDao" ref="productDao"></property> </bean> </beans>
查看完整描述

2 回答

?
FloatingShuYin

TA貢獻4條經驗 獲得超3個贊

只是拼錯了單詞 ?謝了

查看完整回答
反對 回復 2016-10-12
  • 2 回答
  • 0 關注
  • 2249 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號