title: Spring boot with Google Cloud SQL
body: <p>im trying to deploy my spring boot app to Google App Engine Flex Environment and G Cloud MySQL DB.</p>
  
  <p>I'm having issues connecting to the db.</p>
  
  <p>Tried already some variants, but all unsuccessful.
  <a href="https://stackoverflow.com/questions/37194125/spring-boot-with-google-cloud-datastore-api-fails-to-run">spring-boot-with-google-cloud-datastore-api-fails-to-run</a></p>
  
  <p>My properties:</p>
  
  <pre><code>spring:
  profiles: googlecloud
    jpa:
      database: MYSQL
      show-sql: false
      hibernate:
        ddl-auto: update
    datasource:
      url: jdbc:mysql://google/myproject?cloudSqlInstance=XXXX&amp;user=xxx&amp;password=xxx
  </code></pre>
  
  <p>My pom.xml (the db dependencies only):</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;6.0.6&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.cloud.sql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-socket-factory&lt;/artifactId&gt;
          &lt;version&gt;1.0.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;persistence-api&lt;/artifactId&gt;
          &lt;version&gt;1.0.2&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>With this configuration, im getting:</p>
  
  <p>Loading class <code>com.mysql.jdbc.Driver'. This is deprecated. The new driver class is</code>com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.</p>
  
  <p>Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.SocketFactory</p>
  
  <p>...Error creating repository beans...</p>
  
  <p>java.lang.NoClassDefFoundError: com/mysql/jdbc/SocketFactory</p>