question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

spring.cloud.gcp.sql.enabled is ignored if specified in application.properties

See original GitHub issue

Describe the bug Introduced in https://github.com/GoogleCloudPlatform/spring-cloud-gcp/pull/131

The spring.cloud.gcp.sql.enabled variable is ignored if it’s set using application.properties. I’m not sure if this is a deliberate design choice since EnvironmentPostProcessor runs before those properties are applied.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
snicollcommented, Feb 8, 2021

If the EnvironmentPostProcessor runs in the bootstrap context, it can only see what Spring Cloud has initiated. At that point, the application actually hasn’t even started and none of the usual environment preparation has happened yet.

This is unfortunately a limitation of how the bootstrap context was designed and that lead to significant issues when using this feature with Spring Cloud Config Server (see https://github.com/spring-cloud/spring-cloud-commons/issues/737 for instance). The good news is that Spring Cloud 2020.0 has deprecated the bootstrap context in favour of a new mechnism introduced in Spring Boot 2.4 that makes this problem go away, see https://github.com/spring-cloud/spring-cloud-commons/issues/608#issuecomment-626340364.

1reaction
meltsufincommented, Jan 26, 2021

@Dattish I think you’re right that this has something to do with using bootstrap dependencies. In your setup, when Spring invokes the CloudSqlEnvironmentPostProcessor it doesn’t see properties from application.properties. Of course, if you remove spring-cloud-gcp-starter-sql-postgresql from your pom.xml CloudSqlEnvironmentPostProcessor will be disabled because it won’t be on the classpath anymore.

cc/ @snicoll In case you have some insight on why an EnvironmentPostProcessor might not be able to see application.properties when boostrap.properties is in the picture.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A database name must be provided error when trying to ...
When postgresql & spring-cloud-gcp-starter are in the dependencies, spring cloud will try to configure the database. This looks like a bug, as ...
Read more >
Spring Cloud GCP
If you provide your own spring.datasource.url , it will be ignored, unless you disable Cloud SQL auto configuration with spring.cloud.gcp.sql.enabled=false ...
Read more >
Integrate Cloud Spanner with Spring Data - Google Cloud
Specify an instance and database. To specify the default instance and database, set the following configuration properties for your application: Property ...
Read more >
Deploy a Spring Boot Application to Google App Engine
A detailed tutorial to deploying a Spring Boot app using MySQL to Google App Engine.
Read more >
Getting Started with Spring Cloud GCP: Cloud SQL - Medium
In my last article, I gave a general overview of Spring Cloud GCP, explaining its ... Add dependencies; Set application properties ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found