2013-04-07 134 views
0

我嘗試遵循一個講解Spring與Hibernate的教程。 我使用Spring Framework 3.2和創建我自己的庫包含了所有的罐子框架和我有另一個庫冬眠4 我做同樣的例子,但我仍然有這樣的信息:Spring與休眠的IDE

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:aop="http://www.springframework.org/schema/aop" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:tx="http://www.springframework.org/schema/tx" 
     xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd 
      http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd 
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd 
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"> 

    <bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource"> 
    <property name="driverClassName" value="org.postgresql.Driver"/> 
    <property name="url" value="jdbc:postgresql:T"/> 
    <property name="username" value="postgres"/> 
    <property name="password" value="root"/> 
    </bean> 

    <bean id="SessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 
    <property name="datasource" ref="datasource"/>**No setter found for property 'datasource' in class 
    'org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean'** 
    <property name="annotatedClasses"> 
    <list> 
    <value>com.model.Cours</value> 
    <value>com.model.Student</value> 
    </list> 
    </property> 


    </bean> 
    </beans> 

爲什麼請?如果可能的話,我請求提案 是否存在annotation.AnnotationSessionFactoryBean問題。我與hibernate4 工作,它不存在hibernate4.annotation ...

+0

我想你忘了粘貼信息。 – 2013-04-07 14:14:51

+0

你的類路徑上有PostGre驅動嗎? – 2013-04-07 14:23:55

+0

這是editeur eclipse顯示的消息:在類 'org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean' – FERESSS 2013-04-07 14:46:38

回答

1

這是一個錯字,應該是<property name="dataSource" ref="datasource"/>,不<property name="datasource" ref="datasource"/>

NAME = 「數據源」沒有NAME = 「數據源」

+0

非常感謝你。 :)我真的很感激它OK – FERESSS 2013-04-07 15:45:02

+1

@FERESSS一個感激的人會接受他的回答;) – 2013-04-07 21:59:51