【发布时间】:2020-06-08 16:25:48
【问题描述】:
我正在将旧的 Spring 应用程序转换为 Spring boot。所以我仍将使用现有的 xml 配置而不是注释。在 appContext.xml 中,我配置了要从应用程序属性中读取的休眠属性,如下所示。
<bean id="appSessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${spring.jpa.database-platform}</prop>
<prop key="hibernate.show_sql">${spring.jpa.show-sql}</prop>
<prop key="hibernate.format_sql">${spring.jpa.format-sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${spring.jpa.hibernate.ddl-auto}</prop>
<prop key="hibernate.generate_statistics">true</prop>
</props>
</property>
否则这些休眠属性将不会仅通过使用 application.properties 来设置。但是数据源是通过读取 application.properties 文件自动创建的。谁能告诉我休眠属性缺少什么?我绝对希望保留 appContext.xml,因为将其更改为使用注释只需要大量重构。
这是我的 application.properties。
spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource
spring.datasource.url=xxxxxx
spring.datasource.username=xxxx
spring.datasource.password=xxxxx
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.tomcat.initial-size=15
spring.datasource.tomcat.max-wait=20000
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-idle=15
spring.datasource.tomcat.min-idle=8
spring.datasource.tomcat.default-auto-commit=true
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=true
spring.jpa.format-sql=false
【问题讨论】:
标签: hibernate spring-boot