4
In the project we are creating, on site, to the initial JPA - Ibernate, created the tables and inserted some information, for tests.
Well the project was growing and we decided to include the flyway for versioning tables, since we have seen that this project does this.
Before we put the flyway , the application_core.properties it was like that:
spring.datasource.url=jdbc:postgresql://localhost/usuarios spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.username=postgres spring.datasource.password= spring.jpa.hibernate.ddl-auto=create spring.data.rest.base-path=/usuarios/api server.port=8090 spring.jpa.generate-ddl=true spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=false spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=false spring.jpa.properties.org.hibernate.envers.default_schema=event_log logging.level.root=INFO logging.level.org.hibernate.SQL=INFO logging.level.org.springframework=INFO
That is, when starting the server, it automatically created the table, index, Constraint in the database.
now it’s like this:
spring.datasource.url=jdbc:postgresql://localhost/usuarios spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.username=postgres spring.datasource.password= spring.jpa.hibernate.ddl-auto=none spring.data.rest.base-path=/usuarios/api server.port=8090 spring.jpa.generate-ddl=true spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=false spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=false spring.jpa.properties.org.hibernate.envers.default_schema=event_log logging.level.root=INFO logging.level.org.hibernate.SQL=INFO logging.level.org.springframework=INFO
I mean, the property spring.jpa.Hibernate.ddl-auto era create and became None.
Only that even passing the spring.jpa.Hibernate.ddl-auto for None, the JPA - Ibernate is creating tables automatically.
The project is divided into modules core, Rest, useful and flyway.
In each module has a configuration:
Module flyway:
@Configuration
@EnableAspectJAutoProxy
@EntityScan(ConfiguracaoFlyway.PACOTE)
@ComponentScan({ ConfiguracaoFlyway.PACOTE })
@EnableJpaRepositories(basePackages = ConfiguracaoFlyway.PACOTE)
@PropertySource("classpath:application_flyway.properties")
public class ConfiguracaoFlyway {
static final String PACOTE = "br.com.ghsistemas.usuarios.flyway";
}
Module core:
@Configuration
@EnableJpaAuditing
@EnableAspectJAutoProxy
@EntityScan(ConfiguracaoCore.PACOTE)
@ComponentScan({ ConfiguracaoCore.PACOTE })
@EnableJpaRepositories(basePackages = ConfiguracaoCore.PACOTE)
@PropertySource("classpath:application_core.properties")
public class ConfiguracaoCore {
static final String PACOTE = "br.com.ghsistemas.usuarios.core";
}
The application_flyway.properties is like this:
flyway.driver=org.postgresql.Driver flyway.urll=jdbc:postgresql://localhost/usuarios flyway.user=postgres flyway.password= flyway.schemas=public
What can it be ?
Have you tried fully removing the property
spring.jpa.hibernate.ddl-auto
of the archive?– StatelessDev
I’ll test and report here
– Guilherme Costa Lopes
Try to remove this property tbm
spring.jpa.generate-ddl=true
– Amanda Lima