在pom.xml依赖中添加configuration内容,如下:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>4.2.0</version>
<!-- configuration配置 url,user,password不然plugin无法正常使用 -->
<configuration>
<url>jdbc:mysql://localhost:3306/scis?useUnicode=true&zeroDateTimeBehavior=convertToNull&autoReconnect=true&characterEncoding=utf-8&serverTimezone=CTT</url>
<user>root</user>
<password>123456</password>
</configuration>
</plugin>
测试flyway info执行结果:
"C:\Program Files\Java\jdk1.8.0_231\bin\java.exe" -Dmaven.multiModuleProjectDirectory=D:\springgw\scis-master -Dmaven.home=D:\apache-maven-3.6.3 -Dclassworlds.conf=D:\apache-maven-3.6.3\bin\m2.conf "-Dmaven.ext.class.path=D:\IntelliJ IDEA 2020.1.2\plugins\maven\lib\maven-event-listener.jar" "-javaagent:D:\IntelliJ IDEA 2020.1.2\lib\idea_rt.jar=57367:D:\IntelliJ IDEA 2020.1.2\bin" -Dfile.encoding=UTF-8 -classpath D:\apache-maven-3.6.3\boot\plexus-classworlds-2.6.0.jar;D:\apache-maven-3.6.3\boot\plexus-classworlds.license org.codehaus.classworlds.Launcher -Didea.version2020.1.2 -s D:\apache-maven-3.6.3\conf\settings.xml -Dmaven.repo.local=D:\apache-maven-3.6.3\repository org.flywaydb:flyway-maven-plugin:4.2.0:info
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------------< com.jcohy:scis >---------------------------
[INFO] Building scis 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- flyway-maven-plugin:4.2.0:info (default-cli) @ scis ---
[INFO] Flyway 4.2.0 by Boxfuse
Thu Jul 09 09:13:11 GMT+08:00 2020 WARN: Establishing SSL connection without server‘s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn‘t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false‘. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
[INFO] Database: jdbc:mysql://rm-2zed2d1o5ujtu72g7no.mysql.rds.aliyuncs.com:3306/scis?useUnicode=true&zeroDateTimeBehavior=convertToNull&autoReconnect=true&characterEncoding=utf-8&serverTimezone=CTT (MySQL 8.0)
[INFO]
+------------------+------------------------+---------------------+---------+
| Version | Description | Installed on | State |
+------------------+------------------------+---------------------+---------+
| 1.0.0.20180406.1 | SCIS DB INIT | 2020-06-29 14:46:08 | Success |
| 1.0.0.20180407.1 | ADD TABLE ALLOTPRO | 2020-06-29 14:46:10 | Success |
| 1.0.0.20180410.2 | ADD TABLE Notice | 2020-06-29 14:46:11 | Success |
| 1.0.0.20180416.1 | ADD TABLE FIELD | 2020-06-29 14:46:13 | Success |
| 1.0.0.20180416.2 | ADD SOME DATA | 2020-06-29 14:46:16 | Success |
| 1.0.0.20180510.1 | ADD TABLE CIRCULAR | 2020-06-29 14:46:18 | Success |
| 1.0.0.20180510.2 | ADD TABLE FIELD | 2020-06-29 14:46:19 | Success |
| 1.0.0.20180510.3 | ADD TABLE FIELD | 2020-06-29 14:46:20 | Success |
| 1.0.0.20180517.1 | ADD TABLE FIELD | 2020-06-29 14:46:21 | Success |
| 1.0.0.20180517.2 | ADD FORGIN KEY | 2020-06-29 14:46:23 | Success |
| 1.0.0.20180517.3 | CHANGE CIRCULAR FIELD | 2020-06-29 14:46:24 | Success |
| 1.0.0.20180518.1 | ADD PROJECT DATE | 2020-06-29 14:46:26 | Success |
| 1.0.0.20180522.1 | DELETE PROJECT FIELD | 2020-06-29 14:46:27 | Success |
| 1.0.0.20180524.1 | CHANGE NUM FIELD | 2020-06-29 14:46:29 | Success |
| 1.0.0.20180525.1 | ADD DEPT FIELD | 2020-06-29 14:46:31 | Success |
| 1.0.0.20180527.1 | ADD DEPT FIELD | 2020-06-29 14:46:33 | Success |
| 2.0.0.20200708.1 | SCIS DB INIT | 2020-07-08 17:50:50 | Success |
+------------------+------------------------+---------------------+---------+
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.237 s
[INFO] Finished at: 2020-07-09T09:13:12+08:00
[INFO] ------------------------------------------------------------------------
flyway maven plugin无法正常使用: Unable to connect to the database. Configure the url, user and password!