【问题标题】:Spring Data configuration - hibernate.properties not foundSpring Data 配置 - hibernate.properties 未找到
【发布时间】:2017-01-26 05:59:11
【问题描述】:

我尝试使用 Hibernate 内存数据库配置 Spring Data,基于 thisthis 答案:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd

   http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">

<!-- Configure the data source bean -->
<jdbc:embedded-database id="dataSource" type="HSQL">
</jdbc:embedded-database>

<!-- Create default configuration for Hibernate -->
<bean id="hibernateJpaVendorAdapter"
      class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    <property name="generateDdl" value="false">
    </property>
</bean>

<!-- Configure the entity manager factory bean -->
<bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter"/>
    <property name="persistenceUnitName" value="punit"/>
    <property name="jpaPropertyMap">
        <map>
            <entry key="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"></entry>
            <entry key="hibernate.hbm2ddl.auto" value="create"></entry>
            <entry key="hibernate.show_sql" value="true"></entry>
        </map>
    </property>
    <property name="packagesToScan" value="models"/>
    <property name="sharedCacheMode" value="ENABLE_SELECTIVE"/>
    <property name="validationMode" value="NONE"/>
</bean>
<bean id="transactionManager"
      class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven/>
<jpa:repositories base-package="beans.repositories"/>

但我一遍又一遍地得到:

org.hibernate.cfg.Environment。 HHH000206: hibernate.properties 未找到

问题是我不想在properties 文件中指定它,因为我以前没有Spring Data,我想在xml 配置中设置它,就像我基于的答案一样。我错过了什么吗?提前感谢您的每一个帮助。

【问题讨论】:

  • 忽略该消息。这只是来自 hibernate 的一条信息消息...您可能也会收到 hibernate.cfg.xml 的消息。
  • @M.Deinum 你是对的,我认为这是应用程序不会部署到 Tomcat 的原因,但问题不同。请把你的答案写成正常答案,我会接受的。

标签: java spring hibernate spring-data spring-data-jpa


【解决方案1】:

该行只不过是来自 Hibernate 的信息消息。您可能会收到另一个与此类似的抱怨 hibernate.cfg.xml

在启动时,可以使用这 2 个文件配置休眠模式,并且休眠会记录这些文件的缺失。不多不少。你可以直接忽略它。

【讨论】:

    猜你喜欢
    • 2013-07-02
    • 2011-06-12
    • 2022-08-05
    • 2016-02-29
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 2012-05-10
    相关资源
    最近更新 更多