Reputation: 324
I have problem with hibernate.ddl-auto: none in spring. It works fine in development environment and does not execute sql's like drop table. But in production environment same property seems like it's not working. And execute drop and create tables sql's. In application.yaml on production:
spring:
jpa:
hibernate.ddl-auto: none
I checked this value in application by this:
@Bean
public CommandLineRunner initProject() {
return (args) -> {
logger.info(env.getProperty("spring.jpa.hibernate.ddl-auto")); //this prints "create"
So it looks like some internal code changed it value. I run application by this command:
./mvnw spring-boot:run
Upvotes: 0
Views: 2766
Reputation: 6936
The value has to come from somewhere...
You can easily trace this if you have actuator
enabled
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
And expose the env
endpoint via
management:
endpoints:
web:
exposure:
include: env
Then you can visit that endpoint via /actuator/env
Here you can even find the location where you have defined the value.
{
"name": "Config resource 'class path resource [application.yaml]' via location 'optional:classpath:/'",
"properties": {
"spring.jpa.hibernate.ddl-auto": {
"value": "none",
"origin": "class path resource [application.yaml] - 3:25"
},
"management.endpoints.web.exposure.include": {
"value": "env",
"origin": "class path resource [application.yaml] - 9:18"
}...
Upvotes: 4
Reputation: 499
The value none is undocumented, use validate instead. See also:What are the possible values of the Hibernate hbm2ddl.auto configuration and what do they do
Upvotes: 0