【发布时间】:2020-10-29 12:18:47
【问题描述】:
我正在使用带有 Java 11 的 Spring Boot 2.1。我正在使用 Maven 来构建我的工件。在本地运行时,我喜欢让我自动创建数据库的 Spring JPA 指令...
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.show-sql=true
我也喜欢让我自动创建文件的指令...
spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
spring.jpa.properties.javax.persistence.schema-generation.scripts.action=update
spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=update.sql
但是,当我在我的 src/main/resources/application.properties 中结合两者时...
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.show-sql=true
spring.jpa.properties.javax.persistence.validation.mode=none
spring.datasource.url=jdbc:postgresql://${PG_DB_HOST:localhost}:5432/${PG_DB_NAME}
spring.datasource.username=${PG_DB_USER}
spring.datasource.password=${PG_DB_PASS}
spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
spring.jpa.properties.javax.persistence.schema-generation.scripts.action=update
spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=update.sql
似乎“spring.jpa.properties.javax.persistence”优先,并且我的架构更改不会针对数据库自动运行。有没有办法配置这两种情况——更改被记录到文件中并自动针对我的数据库运行?
【问题讨论】:
标签: spring-boot maven jpa spring-data-jpa spring-boot-2