[英]Spring boot App Deploying to Heroku with Google cloud Mysql
I have spring boot app and I want to deploy Heroku. 我有春季启动应用程序,我想部署Heroku。 But my database at Google cloud. 但我在Google云端的数据库。 The app connect to database when I deploy to local tomcat server but Heroku can not connect to database. 当我部署到本地tomcat服务器时,应用程序连接到数据库,但Heroku无法连接到数据库。
1) Local app connects because I use 'gcloud auth application-default login' command and the './mvnw -DskipTests spring-boot:run' as a result I connect to google cloud mysql database. 1)本地应用程序连接,因为我使用'gcloud auth application-default login'命令和'./mvnw -DskipTests spring-boot:run',因此我连接到google cloud mysql数据库。
2) when I give an my ip to google for my sql connection, the app connects but heroku doesn't. 2)当我给我的IP谷歌我的SQL连接,该应用程序连接但heroku没有。 In this case I need to my heroku apps' ip. 在这种情况下,我需要我的heroku应用程序的IP。
Caused by: java.lang.RuntimeException: Unable to obtain credentials to communicate with the Cloud SQL API
at com.google.cloud.sql.mysql.SslSocketFactory$ApplicationDefaultCredentialFactory.create(SslSocketFactory.java:548)
at com.google.cloud.sql.mysql.SslSocketFactory.getInstance(SslSocketFactory.java:141)
at com.google.cloud.sql.mysql.SocketFactory.connect(SocketFactory.java:47)
at com.mysql.jdbc.SocketFactoryWrapper.connect(SocketFactoryWrapper.java:57)
at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65)
at com.mysql.cj.NativeSession.connect(NativeSession.java:152)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:955)
... 82 common frames omitted
The Cloud SQL JDBC Socket Factory uses the Application Default Credentials (ADC) strategy for finding credentials. Cloud SQL JDBC套接字工厂使用应用程序默认凭据 (ADC)策略来查找凭据。
You can manually supply credentials using the GOOGLE_APPLICATION_CREDENTIALS
enviroment variable to point to a service account. 您可以使用GOOGLE_APPLICATION_CREDENTIALS
环境变量手动提供凭据,以指向服务帐户。 You can find more detailed instructions here . 您可以在此处找到更详细的说明 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.