1

I set 'spring.jpa.hibernate.ddl-auto = update' property in application.properties file, and also am using 'data.sql' to load some seed-data.

When I run my spring-boot project 'First Time', all Tables and seed-data loaded to DB.

If I run again my spring-boot project for 'Second Time', here I need to block execution of 'data.sql'.

now am getting 'com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1' for key 'PRIMARY' ' because of loaded old seed-data.

Patrick
  • 12,336
  • 15
  • 73
  • 115

1 Answers1

0

One option to make sure that spring-boot does not fail-fast is to set the property: spring.datasource.continue-on-error=true.

By default, Spring Boot enables the fail-fast feature of the Spring JDBC initializer. This means that, if the scripts cause exceptions, the application fails to start. You can tune that behavior by setting spring.datasource.continue-on-error.

That does not solve the issue but should start your application.

Patrick
  • 12,336
  • 15
  • 73
  • 115