title: Spring config for deployment on google app engine flex connecting to cloud sql
body: <p>I know there is a lot of issues like that in here but I couldn't find the solution to my problem.
  I'm trying to find a way to make that project working on google app engine flex connecting to cloud sql in the same app engine project.</p>
  
  <p>For that I use the code from <a href="https://github.com/hellokoding/registration-login-spring-xml-maven-jsp-mysql" rel="nofollow noreferrer">git</a>
  I have the 3 files where to set the config: pom.xml, app.yaml, application.properties</p>
  
  <p>I tried to add properties and dependencies to my pom.xml as said <a href="https://cloud.google.com/appengine/docs/flexible/java/using-cloud-sql" rel="nofollow noreferrer">on google</a></p>
  
  <pre><code>&lt;properties&gt;
      &lt;INSTANCE_CONNECTION_NAME&gt;project:region:instance&lt;/INSTANCE_CONNECTION_NAME&gt;
      &lt;user&gt;myUser&lt;/user&gt;
      &lt;password&gt;myPassword&lt;/password&gt;
      &lt;database&gt;accounts&lt;/database&gt;
      &lt;sqlURL&gt;jdbc:mysql://google/${database}?cloudSqlInstance=${INSTANCE_CONNECTION_NAME}&amp;amp;socketFactory=com.google.cloud.sql.mysql.SocketFactory&amp;amp;user=${user}&amp;amp;password=${password}&amp;amp;useSSL=false&lt;/sqlURL&gt;
  &lt;/properties&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.google.cloud.sql&lt;/groupId&gt;
      &lt;artifactId&gt;mysql-socket-factory-connector-j-6&lt;/artifactId&gt;
      &lt;version&gt;1.0.5&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I have my application.properties that contain value for the spring data-source (urls with IP and port works fine locally)</p>
  
  <pre><code>jdbc.driverClassName=com.mysql.jdbc.Driver
  jdbc.url=jdbc:mysql://google/myDatabase?cloudSqlInstance=project:region:instance=com.google.cloud.sql.mysql.SocketFactory
  #jdbc.url=jdbc:mysql://IP_ADDRESS:PORT/myDatabase?    useUnicode=true&amp;characterEncoding=UTF-8&amp;zeroDateTimeBehavior=convertToNull
  #jdbc.url=mysql:unix_socket=/cloudsql/project:region:instance;dbname=myDatabase
  jdbc.username=myUser
  jdbc.password=myPassword
  </code></pre>
  
  <p>I tried different url as you can see.</p>
  
  <p>I also tried to add some lines in my app.yaml</p>
  
  <pre><code>resources:
    memory_gb: 2.3
  
  handlers:
    - url: /.*
      script: this field is required, but ignored
  </code></pre>
  
  <p>or these</p>
  
  <pre><code>env_variables:
    MYSQL_DNS: mysql:unix_socket=/cloudsql/project:region:instance;dbname=myDatabase
    MYSQL_USER: myUser
    MYSQL_PASSWORD: myPassword
  </code></pre>
  
  <p>or both.</p>
  
  <p>I run out of idea. anyone can help me?</p>