无法将Flyway迁移与Google Cloud SQL和Maven一起使用
我只是想用maven、flyway和Google Cloud SQL建立一个简单的Hello World概念验证。有关我使用的完整代码,请参阅。(问题张贴在提交时) 无论何时运行无法将Flyway迁移与Google Cloud SQL和Maven一起使用,maven,google-cloud-sql,flyway,Maven,Google Cloud Sql,Flyway,我只是想用maven、flyway和Google Cloud SQL建立一个简单的Hello World概念验证。有关我使用的完整代码,请参阅。(问题张贴在提交时) 无论何时运行mvn flyway:migrate,无论从哪台机器运行,都会出现以下错误: [ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:4.0.2:migrate (default-cli) on project mvn-flyway-cloudsql
mvn flyway:migrate
,无论从哪台机器运行,都会出现以下错误:
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:4.0.2:migrate (default-cli) on project mvn-flyway-cloudsql-test: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call rdbms.OpenConnection in a thread that is neither the original request thread nor a thread created by ThreadManager -> [Help 1]
以下是我的pom.xml:
<!--
mvn-flyway-cloudsql-test is an example of how to set up a Maven/Flyway/Google CloudSQL integration.
Copyright (C) 2017 Christopher R. Reyes
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>reyes.r.christopher</groupId>
<artifactId>mvn-flyway-cloudsql-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mvn-flyway-cloudsql-test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.54</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>4.0.2</version>
<configuration>
<!--
Normally, I would specify these in a flyway.properties file.
Since I don't want to check in my actual instance address, username, and password to a public git repository, I'll do this instead.
-->
<url>jdbc:google:rdbms://${instance}:3306/hello_world?serverTimezone=UTC&useSSL=true&verifyServerCertificate=true&requireSSL=true</url>
<user>${user}</user>
<password>${password}</password>
<driver>com.google.appengine.api.rdbms.AppEngineDriver</driver>
</configuration>
</plugin>
</plugins>
</build>
</project>
我已经确认,我可以使用gcloud工具使用相同的凭据直接登录到云sql:gcloud sql connect-REDACTED--user=$user
。当我在打开的mysql工具中键入\s
时,我可以确认用户是相同的,并且连接与我一直使用的$instance
相同。在尝试mvn flyway:migrate
之前和之后,我都尝试过使用gcloud
工具,但它没有改变错误消息
我看了一下,但我的错误信息不同。我无论如何都尝试了修复(放入mysql jdbc jar),但它根本没有改变错误消息
谢谢你的帮助 我在谷歌与Jinjun交谈,他能给我指出一些。我需要使用它们的url并重新格式化JDBCURL字符串 具体而言,我在pom.xml中添加了以下依赖项:
<!-- https://mvnrepository.com/artifact/com.google.cloud.sql/mysql-socket-factory-connector-j-6 -->
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory-connector-j-6</artifactId>
<version>1.0.2</version>
</dependency>
我已经更新了我的,并在一些不同的机器上测试了它,以测试可移植性。此外,如果配置文件中有jdbc连接器字符串,则不需要HTML转义符号(
&;
)
<!-- https://mvnrepository.com/artifact/com.google.cloud.sql/mysql-socket-factory-connector-j-6 -->
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory-connector-j-6</artifactId>
<version>1.0.2</version>
</dependency>
jdbc:mysql://google/hello_world?cloudSqlInstance=${instance}&socketFactory=com.google.cloud.sql.mysql.SocketFactory