【问题标题】:spring-data embadded-database configurationspring-data 嵌入数据库配置
【发布时间】:2013-07-29 20:40:48
【问题描述】:

我尝试使用嵌入式数据库配置 springdata。上下文文件灵感来自http://cooldevstuff.wordpress.com/2012/09/20/in-memory-database-using-spring-3-2/

我的上下文文件:

    <jdbc:embedded-database id="embeddedDataSource">
    <jdbc:script location="classpath:schemaFile.sql" />
    <jdbc:script location="classpath:dataFile.sql" />
    </jdbc:embedded-database>

<jpa:repositories base-package="aa.bb.repository" />

<bean class="org.springframework.orm.hibernate4.HibernateExceptionTranslator" />

<bean id="entityManagerFactory">
    <property name="dataSource" ref="embeddedDataSource" />
    <property name="persistenceUnitName" value="SamplePU"></property>
</bean>

但我得到错误: 没有定义类型为 [javax.persistence.EntityManagerFactory] ​​的唯一 bean:预期为单个 bean,但发现为 0。

我错过了什么?

【问题讨论】:

    标签: jpa repository spring-data embedded-database


    【解决方案1】:

    配置无效。您的 bean entityManagerFactory 没有声明任何 class 属性。

    【讨论】:

    • 我尝试使用例如class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">同样的问题...
    猜你喜欢
    • 1970-01-01
    • 2019-07-24
    • 2016-02-28
    • 2015-10-07
    • 1970-01-01
    • 1970-01-01
    • 2011-01-02
    • 2014-05-05
    • 2014-11-17
    相关资源
    最近更新 更多