-
Notifications
You must be signed in to change notification settings - Fork 41.1k
@Sql annotation on tests makes schema.sql executed twice #7416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
status: duplicate
A duplicate of another issue
Comments
The problem doesn't occur with Spring Boot 1.4.3 because the two contexts no longer share an in-memory database. However, we believe that there shouldn't be two contexts in the first place as the SQL specified in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample to reproduce: https://github.com/savinov/spring-boot-schema-twice
spring-boot 1.4.1, spring-data-jpa, hsqldb (for tests). There is
schema.sql
anddata.sql
in the test resources folder. Four test classese are annotated with@RunWith(SpringRunner.class)
,@DataJpaTest
and@Sql
. One test class (SchemaTwice3Test
) is annotated only with@RunWith(SpringRunner.class)
and@DataJpaTest
.Run tests:
mvn test
The problem is:
schema.sql
is executed twice somewhere betweenSchemaTwice3Test
run and other tests run. If add (uncomment)@Sql
annotation to theSchemaTwice3Test
then there is no problems. If remove (comment)@Sql
annotation from all the test-classes then there is no problems too.Workarond with
spring.datasource.continueOnError=true
makes all the tests pass, but it's not a solution.It seems that there is some initialization incompartability between
@Sql
annotation andorg.springframework.boot.autoconfigure.jdbc.DataSourceInitializer
.The text was updated successfully, but these errors were encountered: