I have two sql datasources already working locally, but I want to deploy it to two google cloud app-engines (I have it working with one right now). What do I need to change in my application-properties to define a second google instance/database?
I already have links set up in my pom for connections called sql.instance.second
and sql.database.second
. I don't know how to define spring.cloud.gcp.sql...
for a second app-engine. Another option I have is to not run it locally at all but just define a cloud instance when I'm defining the datasources and then define a driver for each, but I'm not too sure how to do that either.
spring.cloud.gcp.sql.instance-connection-name=@sql.instance.first@
[email protected]@
primary.datasource.jdbc-url = @mysql.host.first@
primary.datasource.username = @mysql.user.first@
primary.datasource.password = @mysql.pass.first@
secondary.datasource.jdbc-url = @mysql.host.second@
secondary.datasource.username = @mysql.user.second@
secondary.datasource.password = @mysql.pass.second@
I was able to get it working by getting rid of this dependency first
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-sql-mysql</artifactId>
</dependency>
Then changing my application.properties
to this
primary.datasource.driverClassName=com.mysql.jdbc.GoogleDriver
primary.datasource.jdbc-url = @mysql.host.first@
primary.datasource.username = @mysql.user.first@
primary.datasource.password = @mysql.pass.first@
secondary.datasource.driverClassName=com.mysql.jdbc.GoogleDriver
secondary.datasource.jdbc-url = @mysql.host.second@
secondary.datasource.username = @mysql.user.second@
secondary.datasource.password = @mysql.pass.second@
And deleting
spring.cloud.gcp.sql.instance-connection-name=@sql.instance.first@
[email protected]@
Change the url of @mysql.host.first@
in my pom.xml to
<mysql.host.first>jdbc:google:mysql:...</mysql.host.first>