Spring 弹簧靴&x2B;冬眠+;Grails忽略yml文件中的ddlAuto
我不希望Hibernate重新创建或更新数据库架构 根据文档,您需要在application.yml文件中包含以下内容:Spring 弹簧靴&x2B;冬眠+;Grails忽略yml文件中的ddlAuto,spring,hibernate,grails,spring-boot,gorm,Spring,Hibernate,Grails,Spring Boot,Gorm,我不希望Hibernate重新创建或更新数据库架构 根据文档,您需要在application.yml文件中包含以下内容: spring.jpa.hibernate.ddl-auto:none 它不起作用 这是我的application.yml文件: spring: profiles.active: default spring.jpa.hibernate.ddl-auto: none --- spring: profiles: default spring.datasource:
spring.jpa.hibernate.ddl-auto:none
它不起作用
这是我的application.yml文件:
spring:
profiles.active: default
spring.jpa.hibernate.ddl-auto: none
---
spring:
profiles: default
spring.datasource:
driverClassName: net.sourceforge.jtds.jdbc.Driver
url: jdbc:jtds:sqlserver://IP/DB
username: user
password: password
spring.jpa:
hibernate:
ddlAuto: validate
showSql: true
hibernate:
ddl-auto: none
---
spring:
profiles: unit-test
spring.datasource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password:
dbCreate: create-drop
url: jdbc:h2:mem:devDb;MVCC=FALSE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=TRUE
文档链接:
注意,我也用ddlAuto更改了ddl auto,仍然不起作用
build.gradle:
buildscript {
repositories {
mavenCentral()
jcenter()
maven { url "https://repo.spring.io/libs-release" }
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.2'
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.+"
}
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
apply plugin: 'spring-boot'
dependencies {
//Spring
compile "org.springframework.boot:spring-boot-configuration-processor"
compile "org.springframework.boot:spring-boot-starter"
compile "org.grails:gorm-hibernate4-spring-boot:5.0.+"
compile 'javax.el:javax.el-api:2.2.5'
//DB
testCompile 'com.h2database:h2:1.4.190'
compile 'net.sourceforge.jtds:jtds:1.3.1'
compile 'commons-dbcp:commons-dbcp:1.4'
}
我真的不明白您的问题,您的意思是您不希望grails在grails run app命令期间对数据库进行任何更改吗?try dbCreate:确实尝试过了-它会被忽略。尝试无,也验证-它始终设置为“更新”。