我想在测试执行期间使用我的个人资料'dev'。但是当我运行测试时,无法找到H2 db。 抽象测试类:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MyServiceStarter.class)
@ActiveProfiles("dev")
public abstract class AbstractModulIntegrationTest { ... }
属性:
flyway.locations=filesystem:./database/h2
flyway.enabled=true
# hsqldb
spring.datasource.platform=h2
spring.jpa.hibernate.ddl-auto=validate
spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:./db/gcrs;AUTO_SERVER=TRUE
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.password=
spring.datasource.username=sa
spring.jpa.database=h2
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
当我在输出中运行测试时,它打印无法解析位置:filesystem:./ database / h2
2017-03-14 18:05:24.500 INFO 7460 --- [ main] o.f.core.internal.util.VersionPrinter : Flyway 4.0.3 by Boxfuse
2017-03-14 18:05:24.500 INFO 7460 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Started.
2017-03-14 18:05:25.002 INFO 7460 --- [ main] o.f.c.i.dbsupport.DbSupportFactory : Database: jdbc:h2:./db/gcrs (H2 1.4)
2017-03-14 18:05:25.018 WARN 7460 --- [ main] o.f.c.i.u.s.f.FileSystemScanner : Unable to resolve location filesystem:./database/h2
2017-03-14 18:05:25.049 WARN 7460 --- [ main] o.f.c.i.u.s.f.FileSystemScanner : Unable to resolve location filesystem:./database/h2
2017-03-14 18:05:25.049 WARN 7460 --- [ main] o.f.c.i.u.s.f.FileSystemScanner : Unable to resolve location filesystem:./database/h2
2017-03-14 18:05:25.049 INFO 7460 --- [ main] o.f.core.internal.command.DbValidate : Successfully validated 0 migrations (execution time 00:00.006s)
2017-03-14 18:05:25.064 INFO 7460 --- [ main] o.f.core.internal.command.DbMigrate : Current version of schema "PUBLIC": << Empty Schema >>
2017-03-14 18:05:25.064 INFO 7460 --- [ main] o.f.core.internal.command.DbMigrate : Schema "PUBLIC" is up to date. No migration necessary.
2017-03-14 18:05:25.205 INFO 7460 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-03-14 18:05:25.220 INFO 7460 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
Spring boot版本:1.5.1.RELEASE
答案 0 :(得分:0)
我的同事找到了解决方案。问题出在了错误的道路上。这解决了我的问题:
@SpringBootTest(classes = MyServiceStarter.class, properties = {"flyway.locations=filesystem:../database/h2"})