Вот моя структура папки: < /p>
Код: Выделить всё
main
-resources
-application.properties
-data.sql
test
-resources
-application.properties
-data.sql
Например, вот файл тестирования:
Код: Выделить всё
@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>
Я попытался изменить имена, играть с моим файлом свойств и т. Д., Но я не добился успеха в получении Spring для загрузки файла тестовых данных для моего теста. Есть предложения?
Подробнее здесь: https://stackoverflow.com/questions/796 ... a-sql-file