gpt4 book ai didi

google-compute-engine - 无法创建套接字工厂 'com.google.cloud.sql.mysql.SocketFactory;'

转载 作者:行者123 更新时间:2023-12-04 22:07:40 26 4
gpt4 key购买 nike

我似乎无法让这个工作..

我正在使用 Google 柔性环境 并想连接到我的 二代云SQL 数据库。我目前收到此异常:

[main] ERROR com.mahlzeit.server.BootstrappingServerConfig - Error trying to migrate SQL scripts ..
org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSource
at org.flywaydb.core.internal.util.jdbc.JdbcUtils.openConnection(JdbcUtils.java:56)
at org.flywaydb.core.Flyway.execute(Flyway.java:1385)
at org.flywaydb.core.Flyway.migrate(Flyway.java:1006)
...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create socket factory 'com.google.cloud.sql.mysql.SocketFactory;' due to underlying exception:
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
...
Caused by: java.lang.ClassNotFoundException: com/google/cloud/sql/mysql/SocketFactory;
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.mysql.jdbc.MysqlIO.createSocketFactory(MysqlIO.java:3321)
...

这就是我如何配置我的 DataSource :

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://google/mz_db?cloudSqlInstance=mz-test:us-central1:mz-life-cloudsql-prod&amp;socketFactory=com.google.cloud.sql.mysql.SocketFactory;" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>

我添加了 mysql-socket-factory 作为依赖:
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>1.0.0</version>
</dependency>

那么为什么我会收到此异常?

最佳答案

最后有一个分号,所以它试图加载一个名为 com.google.cloud.sql.mysql.SocketFactory; 的类。尝试删除末尾的分号。

关于google-compute-engine - 无法创建套接字工厂 'com.google.cloud.sql.mysql.SocketFactory;',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37647091/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com