无法在Google Cloud Platform中确定合适的驱动程序类

时间:2018-12-09 19:08:39

标签: maven spring-boot google-app-engine google-cloud-platform mysql-connector

在运行我的spring-boot应用程序时,它会在Google云上引发以下错误。

    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is 
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

我的pom.xml:

 <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>6.0.6</version>
    </dependency>
    <dependency>
      <groupId>com.google.cloud.sql</groupId>
      <artifactId>mysql-socket-factory-connector-j-6</artifactId>
      <version>1.0.10</version>
    </dependency>


 SELECT VERSION();
    output:
    5.7.14-google-log

有人可以帮助我解决此问题吗?

1 个答案:

答案 0 :(得分:0)

使用Spring Cloud GCP Cloud SQL MySQL Starter。 它将引入正确的依赖关系进行连接。

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-gcp-starter-sql-mysql</artifactId>
        <version>1.0.0.RELEASE</version>
    </dependency>