为什么应用程序引擎可以';无法使用我的Spring Boot应用程序连接到云SQL?

为什么应用程序引擎可以';无法使用我的Spring Boot应用程序连接到云SQL?,spring,google-app-engine,jdbc,google-cloud-platform,google-cloud-sql,Spring,Google App Engine,Jdbc,Google Cloud Platform,Google Cloud Sql,我正在尝试将我的应用程序引擎应用程序(在JavaSpringBoot中)与云SQL数据库连接起来。部署工作正常,应用程序启动,但阻止与云SQL的连接: main] c.g.cloud.sql.core.CoreSocketFactory : First Cloud SQL connection, generating RSA key pair. main] c.g.cloud.sql.core.CoreSocketFactory : Connecting to Cloud SQL

我正在尝试将我的应用程序引擎应用程序(在JavaSpringBoot中)与云SQL数据库连接起来。部署工作正常,应用程序启动,但阻止与云SQL的连接:

main] c.g.cloud.sql.core.CoreSocketFactory     : First Cloud SQL connection, generating RSA key pair.
main] c.g.cloud.sql.core.CoreSocketFactory     : Connecting to Cloud SQL instance [test-api:europe-west1:test-db] via SSL socket.

// Nothing happens after that !
我做什么?

1) 我使用用户名和密码(例如postgres和postgres)在数据库中创建一个用户

2) 我将此依赖项添加到我的项目中

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

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-gcp-starter-sql-postgresql</artifactId>
    <version>1.1.2.RELEASE</version>
</dependency>
有什么问题吗?

问题是,在
连接到云SQL实例
log之后,什么也没有发生。(见上文)

在发布日志中,我可以看到以下信息:

main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.19]
main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 11980 ms
main] o.s.c.g.a.s.GcpCloudSqlAutoConfiguration : Default POSTGRESQL JdbcUrl provider. Connecting to jdbc:postgresql://google/test?socketFactory=com.google.cloud.sql.postgres.SocketFactory&socketFactoryArg=test-api:europe-west1:test-db&useSSL=false with driver org.postgresql.Driver
main] o.s.c.g.a.s.GcpCloudSqlAutoConfiguration : spring.datasource.url is specified. Not using generated Cloud SQL configuration
main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
main] c.g.cloud.sql.core.CoreSocketFactory     : First Cloud SQL connection, generating RSA key pair.
main] c.g.cloud.sql.core.CoreSocketFactory     : Connecting to Cloud SQL instance [test-api:europe-west1:test-db] via SSL socket.

另一个奇怪的地方是,我指定了
&useSSL=false
,但根据日志,应用程序正在通过SSL套接字连接

这听起来与中发生的事情非常相似。这个问题是一个依赖冲突,过时的番石榴版本导致了问题。你能检查一下你指定的番石榴是什么版本的吗


另外,无需担心使用
&useSSL=false
——JDBC SF始终使用SSL,因此这是有意的

你是不是在试图遵循谷歌的文档?您使用的是App Engine Flex还是Standar?如果您使用的是felxible,我认为本教程对您很有用。
main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.19]
main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 11980 ms
main] o.s.c.g.a.s.GcpCloudSqlAutoConfiguration : Default POSTGRESQL JdbcUrl provider. Connecting to jdbc:postgresql://google/test?socketFactory=com.google.cloud.sql.postgres.SocketFactory&socketFactoryArg=test-api:europe-west1:test-db&useSSL=false with driver org.postgresql.Driver
main] o.s.c.g.a.s.GcpCloudSqlAutoConfiguration : spring.datasource.url is specified. Not using generated Cloud SQL configuration
main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
main] c.g.cloud.sql.core.CoreSocketFactory     : First Cloud SQL connection, generating RSA key pair.
main] c.g.cloud.sql.core.CoreSocketFactory     : Connecting to Cloud SQL instance [test-api:europe-west1:test-db] via SSL socket.