springboot集成flyway异常集合

环境背景:jdk13、apache-maven-3.6.2、IDEA2019.2.4、springboot-2.2.0.RELEASE、flyway6.0.7

 

一、Unable to connect to the database. Configure the url, user and password!

1. 异常背景:通过flyway-maven-plugin插件执行clean操作时

2. 异常详情

Failed to execute goal org.flywaydb:flyway-maven-plugin:6.0.7:clean (default-cli) on project jooq: org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password!

3. 异常原因:pom.xml文件中,通过yaml-properties-maven-plugin插件读取application,yml配置文件内容时,直接操作flyway-maven-plugin插件时不生效

4. 解决方法

将插件配置

 <configuration>
                    <!-- 此处的信息是读取的application.yml中的信息 -->
                    <url>${spring.datasource.url}</url>
                    <user>${spring.datasource.username}</user>
                    <password>${spring.datasource.password}</password>
                    <driver>${spring.datasource.driver-class-name}</driver>
                    <schemas>${spring.flyway.schemas}</schemas>
                    <locations>
                        <!-- 创表的sql的位置 -->
                        <location>filesystem:src/main/resources/db/migration</location>
                    </locations>
                </configuration>

修改为 

<configuration>
                    <url>jdbc:postgresql://127.0.0.1:5432/mydb11</url>
                    <user>postgres</user>
                    <password>1234</password>
                    <driver>org.postgresql.Driver</driver>
                    <schemas>jooq</schemas>
                    <locations>
                        <!-- 创表的sql的位置 -->
                        <location>filesystem:src/main/resources/db/migration</location>
                    </locations>
                </configuration>

5. 查看效果

E:\jdk\jdk-13.0.1\bin\java.exe -Dmaven.multiModuleProjectDirectory=F:\IdeaProjects\jooq -Dmaven.home=E:\maven\apache-maven-3.6.2 -Dclassworlds.conf=E:\maven\apache-maven-3.6.2\bin\m2.conf "-Dmaven.ext.class.path=E:\JetBrains\IntelliJ IDEA 2019.2.3\plugins\maven\lib\maven-event-listener.jar" "-javaagent:E:\JetBrains\IntelliJ IDEA 2019.2.3\lib\idea_rt.jar=53595:E:\JetBrains\IntelliJ IDEA 2019.2.3\bin" -Dfile.encoding=UTF-8 -classpath E:\maven\apache-maven-3.6.2\boot\plexus-classworlds-2.6.0.jar org.codehaus.classworlds.Launcher -Didea.version2019.2.4 -s E:\maven\apache-maven-3.6.2\conf\settings.xml org.flywaydb:flyway-maven-plugin:6.0.7:clean
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.zsx:jooq:jar:1.0-SNAPSHOT
[WARNING] 'dependencies.dependency.scope' for org.springframework.boot:spring-boot-devtools:jar must be one of [provided, compile, runtime, test, system] but is 'true'. @ line 105, column 20
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] ----------------------------< com.zsx:jooq >----------------------------
[INFO] Building jooq 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- flyway-maven-plugin:6.0.7:clean (default-cli) @ jooq ---
[INFO] Flyway Community Edition 6.0.7 by Redgate
[INFO] Database: jdbc:postgresql://127.0.0.1:5432/mydb11 (PostgreSQL 12.0)
[WARNING] Unable to clean unknown schema: "jooq"
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.922 s
[INFO] Finished at: 2019-11-20T09:42:59+08:00
[INFO] ------------------------------------------------------------------------

 

二、Set the current schema in currentSchema parameter of the JDBC URL or in Flyway's schemas property.

1. 异常背景:通过flyway-maven-plugin插件执行clean操作时

2. 异常详情

Failed to execute goal org.flywaydb:flyway-maven-plugin:6.0.7:clean (default-cli) on project jooq: org.flywaydb.core.api.FlywayException: Unable to determine current schema as search_path is empty. Set the current schema in currentSchema parameter of the JDBC URL or in Flyway's schemas property.

3. 异常原因:没有指定schemas

4. 解决方案:添加schemas配置 

<plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>migrate</goal>
                        </goals>
                    </execution>
                </executions>
                <!-- 此处配置可以直接通过插件操作 -->
                <configuration>
                    <url>jdbc:postgresql://127.0.0.1:5432/mydb11</url>
                    <user>postgres</user>
                    <password>1234</password>
                    <driver>org.postgresql.Driver</driver>
                    <schemas>jooq</schemas>
                </configuration>
            </plugin>

三、Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Unable to determine current schema as search_path is empty. Set the current schema in currentSchema parameter of the JDBC URL or in Flyway's schemas property.

1. 异常背景:springboot集成flyway启动主程序时报错

2. 异常详情

E:\jdk\jdk-13.0.1\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:E:\JetBrains\IntelliJ IDEA 2019.2.3\lib\idea_rt.jar=53680:E:\JetBrains\IntelliJ IDEA 2019.2.3\bin" -Dfile.encoding=UTF-8 -classpath F:\IdeaProjects\jooq\target\classes;E:\maven\repository\org\springframework\boot\spring-boot-starter-web\2.2.0.RELEASE\spring-boot-starter-web-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter\2.2.0.RELEASE\spring-boot-starter-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-logging\2.2.0.RELEASE\spring-boot-starter-logging-2.2.0.RELEASE.jar;E:\maven\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;E:\maven\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;E:\maven\repository\org\apache\logging\log4j\log4j-to-slf4j\2.12.1\log4j-to-slf4j-2.12.1.jar;E:\maven\repository\org\apache\logging\log4j\log4j-api\2.12.1\log4j-api-2.12.1.jar;E:\maven\repository\org\slf4j\jul-to-slf4j\1.7.28\jul-to-slf4j-1.7.28.jar;E:\maven\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;E:\maven\repository\org\yaml\snakeyaml\1.25\snakeyaml-1.25.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-json\2.2.0.RELEASE\spring-boot-starter-json-2.2.0.RELEASE.jar;E:\maven\repository\com\fasterxml\jackson\core\jackson-databind\2.10.0\jackson-databind-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\core\jackson-annotations\2.10.0\jackson-annotations-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\core\jackson-core\2.10.0\jackson-core
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值