2013-04-07 133 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