Disable table recreation in Spring Boot application Disable table recreation in Spring Boot application postgresql postgresql

Disable table recreation in Spring Boot application


Your configuration isn't a @Configuration class.

Next to that I suggest that you use the power of Spring Boot. Which means I would suggest removing everything but the DataSource configuration and simply add an application.properties file with the following properties

spring.jpa.database=POSTGRESQLspring.jpa.show-sql=falsespring.jpa.hibernate.ddl-auto=update

This should give you the desired behavior, with less coding.

You could even remove the datasource if you have either commons-dbcp or tomcat-pool in your classpath and adding the following properties

spring.datasource.driver-class-name=org.postgresql.Driverspring.datasource.url=jdbc:postgresql://localhost/mydatabasespring.datasource.username=myusernamespring.datasource.password=mypassword


If you are using spring boot, you could do it by configuration over the config file. Hibernate has all this possibilities:

  1. validate (validate the schema)
  2. update (update the schema if are changes)
  3. create (create the schema)
  4. create-drop (create the schema and drop it at the end)

but if you want don't do anything, spring boot add other chance, use as follow:

spring:  jpa:    hibernate:      ddl-auto: none


Your ApplicationConfig is not @Configuration. I imagine that means the Spring Boot autoconfig will also be applied. Can you try adding that?