Code: Select all
main
-resources
-application.properties
-data.sql
test
-resources
-application.properties
-data.sql
Code: Select all
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@ActiveProfiles("test")
public class SomeRepositoryTest { ... }
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.defer-datasource-initialization=true
spring.sql.init.mode=always
spring.sql.init.schema-locations=classpath:data.sql
< /code>
Ich habe versucht, die Namen zu ändern, mit meiner Eigenschaftendatei herumzuspielen, aber ich hatte keinen Erfolg, wenn ich Spring zum Laden der Testdatendatei für meinen Test erhielt. Irgendwelche Vorschläge?