飞行通道和弹簧靴集成
2022-09-01 08:20:00
我试图将Flyway与Hibernate和Spring JPA集成在Spring Boot项目中进行迁移。我得到以下异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Found non-empty schema "PUBLIC" without metadata table! Use init() or set initOnMigrate to true to initialize the metadata table.
我的看起来像这样:pom.xml
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>3.2</version>
</dependency>
我正在使用Hibernate和一个用于postgres(开发阶段)和h2(本地)的配置java文件。签名如下所示:
@Bean(initMethod = "migrate")
public Flyway flyway() {
Flyway fly = new Flyway();
fly.clean();
fly.init();
//flyway.setInitOnMigrate(true);
fly.setSchemas("SBA_DIALOG");
//flyway.setLocations("filesystem:src/main/resources/db/migration");
fly.setDataSource(this.dataSource());
fly.migrate();
return fly;
}
@Bean(name = "sbaEntityManagerFactory") @DependsOn("flyway")
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
...
我找不到有关此问题中描述的问题的任何信息。任何人都可以帮忙吗?