我搜索了很多主题,但没有一个可以帮助我。这是我的情况:
POM.xml中的依赖关系:
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.48</version>
</dependency>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
Java代码:
String jdbcUrl = String.format(
"jdbc:mysql://google/%s?cloudSqlInstance=%s&socketFactory=com.google.cloud.sql.mysql.SocketFactory",
"MyTable",
"xxxx:us-central1:xxxx");
con = DriverManager.getConnection(jdbcUrl, "root", "xxxxxx");
Statement statement = con.createStatement();
ResultSet resultSet = statement.executeQuery("SHOW TABLES");
while (resultSet.next()) {
...
}
当我使用以下方法将应用程序部署到云时,我收到以下错误:
mvn appengine:update
No suitable driver found for jdbc:mysql://google/MyTable?cloudSqlInstance=xxxx:us-central1:xxxx&socketFactory=com.google.cloud.sql.mysql.SocketFactory
据我所知,我的appengine-web.xml中不需要使用google-connector-j
任何人都有线索吗?我差不多两天都在为此苦苦挣扎......
感谢。