SAR*_*ose 6 java spring hibernate spring-annotations hibernate-annotations
如何仅使用Java和注释在Spring中设置以下内容.
<property name="hibernate.hbm2ddl.auto" value="update"/>
我应该是可能的,我相信让xml项目免费更清洁.
PS:这应该不重要,但我在Heroku上运行它.
将此添加到 dataSource() 所在的类中,它解决了我的问题。
final Properties hibernateProperties() {
final Properties hibernateProperties = new Properties();
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "update");
hibernateProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
hibernateProperties.setProperty("hibernate.show_sql", "true");
return hibernateProperties;
}
Run Code Online (Sandbox Code Playgroud)
完整示例在这里https://github.com/arose13/Heroku-Spring-Postgres-Example。
编辑 PS:对于这一行,hibernateProperties.setProperty("hibernate.hbm2ddl.auto","update");请查看此stackoverflow 问题以找出update不适合您的最佳值。
| 归档时间: |
|
| 查看次数: |
8251 次 |
| 最近记录: |