I want to test my spring boot application via h2 in memory database where I would like to use:
spring.jpa.hibernate.ddl-auto: update
However, once I want to run tests with this command:
mvn clean test
it will show some errors which are related to constraint violations (ID must be unique). These ones were caused because the data.sql
file (just with insert statements) is executed more times and hence the data cannot be inserted because of violation consistency.
Is there some way to solve this problem? It would be good to execute data.sql script just once but not sure. Or to load spring boot application context once.
Aucun commentaire:
Enregistrer un commentaire