简体   繁体   English

Google APP Engine 和云 sql :: 无法在 Google 云 sql(我的 sql)中连接 Spring boot 应用程序

[英]Google APP Engine and cloud sql :: Unable to connect Spring boot app in Google cloud sql (my sql)

I am getting this error while connecting my Spring boot APP inside APP engine in Google cloud sql.在 Google Cloud sql 中的 APP 引擎内连接我的 Spring Boot APP 时出现此错误。 在此处输入图片说明

Below I have attached code from application.properties下面我附上了 application.properties 中的代码

spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://google/myprojectID?cloudSqlInstance=myInstance:us-central1:my-sql-instance&socketFactory=com.google.cloud.sql.mysql.SocketFactory
spring.datasource.username=root
spring.datasource.password=myPassword

pom.xml pom.xml

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-gcp-starter</artifactId>
</dependency>

In cloud sql default configuration I have used to create database.在云 sql 默认配置中,我用来创建数据库。 Whenever I fire this command I am getting this error.每当我触发此命令时,我都会收到此错误。

mvn -DskipTests package appengine:deploy mvn -DskipTests 包 appengine:deploy

Based on the @zenny's comment that served as a solution, In order to solve the issue, you've to set private IP in your SQL instance and use that private IP for your database local url.根据作为解决方案的@zenny 的评论,为了解决该问题,您必须在SQL 实例中设置私有 IP,并将该私有 IP 用于您的数据库本地 url。

Here is a Codelabs tutorial which you can follow to set private IP for your SQL instance. 是一个 Codelabs 教程,您可以按照该教程为 SQL 实例设置私有 IP。

I followed this tutorial for Spring Application.我遵循了 Spring Application 的本教程。 Spring Pet Clinic using Cloud SQL 使用 Cloud SQL 的 Spring Pet Clinic

One difference that I noticed was in pom.xml:我注意到的一个区别是在 pom.xml 中:

     ```<!-- Add CloudSQL Starter for MySQL -->
  <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-gcp-starter-sql-mysql</artifactId>
  </dependency>

Also in Spring Cloud GCP :同样在Spring Cloud GCP 中

     SQL - MySQL

     Cloud SQL integrations with MySQL

     org.springframework.cloud:spring-cloud-gcp-starter-sql-mysql

You can find more information Spring Cloud GCP MySQL Sample您可以找到更多信息Spring Cloud GCP MySQL 示例

EDIT:编辑:

I was able to Deploy Spring Boot Application (Pet Clinic) on App Engine standard.我能够在 App Engine 标准上部署 Spring Boot 应用程序(宠物诊所)。 Here you can find my pom.xml在这里你可以找到我的pom.xml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring 启动应用程序在部署到 Google App Engine 时无法连接到 Google Cloud SQL (PostgreSQL) - Spring Boot app can't connect to Google Cloud SQL (PostgreSQL) when deploying to Google App Engine 无法从Google App Engine(春​​季启动应用)连接到Google Cloud SQL(第二代) - Can not connect to google cloud sql(second generation) from google app engine(spring boot app) 使用Google App Engine端点连接到Cloud SQL - Connect to Cloud SQL with Google App Engine Endpoint Google Cloud SQL和Google App Engine - Google Cloud sql and Google app engine 在Eclipse中进行开发时无法从Google App Engine连接到Google Cloud SQL实例 - Unable to connect to Google Cloud SQL instance from Google App Engine when developing in Eclipse 将Google App Engine Eclipse插件连接到Cloud SQL - Connect Google App Engine Eclipse Plugin to Cloud SQL 部署后的Google App Engine和Cloud SQL - Google App Engine and Cloud SQL when deployed 无法连接到Google Cloud SQL - Unable to connect to Google cloud SQL Spring 在 Google Cloud App Engine 上启动托管 - Spring Boot hosting on Google Cloud App Engine 我无法从Google App Engine上已部署的后端Servlet连接到我的Google Cloud sql数据库 - I can't connect to my google cloud sql database from my deployed backend servlet on the google app engine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM