查看此引用:https://docs.kony.com/konylibrary/konyfabric/kony_fabric_manual_install_guide/Content/FlywayNew.htm
它说谷歌云SQL驱动程序需要为flyway cli手动安装,但我如何手动安装它们?我在上面找不到任何文件。
编辑:我把它添加到我的飞行路线中。conf:flyway.jarDirs=/Users/my/flyway
然后我将驱动程序下载到该文件夹中:mvn dependency:get -Ddest=/Users/my/flyway -Dartifact=com.google.cloud.sql:postgres-socket-factory:1.3.0
但当我尝试使用它时,会出现以下错误:The SocketFactory class provided com.google.cloud.sql.postgres.SocketFactory could not be instantiated.
EDIT:这是针对我的DB 运行flyway baseline
时的调试输出
Flyway Community Edition 7.10.0 by Redgate
DEBUG: AWS SDK available: false
DEBUG: Google Cloud Storage available: true
DEBUG: Scanning for filesystem resources at 'sql'
ERROR: Skipping filesystem location:sql (not found).
ERROR: Unexpected error
org.flywaydb.core.internal.exception.FlywaySqlException:
Unable to obtain connection from database (jdbc:postgresql:///mydb ?unixSocketPath=/var/run/cloudsql/ &cloudSqlInstance=my-gcp-project:us-central1:my-cloudsql-instance &socketFactory=com.google.cloud.sql.postgres.SocketFactory &user=jenkins-flyway &password=******************************************) for user 'null': The SocketFactory class provided com.google.cloud.sql.postgres.SocketFactory could not be instantiated.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL State : 08006
Error Code : 0
Message : The SocketFactory class provided com.google.cloud.sql.postgres.SocketFactory could not be instantiated.
at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:71)
at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.<init>(JdbcConnectionFactory.java:68)
at org.flywaydb.core.Flyway.execute(Flyway.java:510)
at org.flywaydb.core.Flyway.baseline(Flyway.java:406)
at org.flywaydb.commandline.Main.executeOperation(Main.java:226)
at org.flywaydb.commandline.Main.main(Main.java:149)
Caused by: org.postgresql.util.PSQLException: The SocketFactory class provided com.google.cloud.sql.postgres.SocketFactory could not be instantiated.
at org.postgresql.core.SocketFactoryFactory.getSocketFactory(SocketFactoryFactory.java:43)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:182)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:223)
at org.postgresql.Driver.makeConnection(Driver.java:465)
at org.postgresql.Driver.connect(Driver.java:264)
at org.flywaydb.core.internal.jdbc.DriverDataSource.getConnectionFromDriver(DriverDataSource.java:268)
at org.flywaydb.core.internal.jdbc.DriverDataSource.getConnection(DriverDataSource.java:232)
at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:55)
... 5 more
Caused by: java.lang.ClassNotFoundException: com.google.cloud.sql.postgres.SocketFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:375)
at org.postgresql.util.ObjectFactory.instantiate(ObjectFactory.java:46)
at org.postgresql.core.SocketFactoryFactory.getSocketFactory(SocketFactoryFactory.java:39)
... 13 more
这是为谷歌云上的Postgres准备的,是吗?
其目的是将驱动程序JAR放入Flyway产品内的drivers
文件夹中(对于v4.0不能100%确定,因为它现在已经很老了——7.11是最新的(。jarDirs
应该可以工作,但它是基于Java的迁移的理想场所。
但是,这看起来像是驱动程序中的一个问题。你是否确保将驱动程序的所有依赖项也放在那里?你能提供一个完整的调试日志(即flyway migrate -X
(和异常详细信息吗?这样我们就可以看看了?
编辑:看看调试日志,这肯定是驱动程序中的一个问题——它无法实例化驱动程序内部的类。