GoogleCloudPlatform / spring-cloud-gcp

New home for Spring Cloud GCP development starting with version 2.0.
Apache License 2.0
414 stars 308 forks source link

spring.cloud.gcp.credentials.location properties is not detected as a valid key #606

Closed kamalhm closed 2 years ago

kamalhm commented 3 years ago

I've stored my credentials on resources, named cred.json, and put this into the properties.application

spring.cloud.gcp.credentials.location=classpath:cred.json

The file was able to be read because there's no FileNotFoundException, but spring cloud didn't detect the credentials and throw this error

Caused by: java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

meltsufin commented 3 years ago

Which dependencies are you including? This property is being read by GcpContextAutoConfiguration, but you must import one of the Spring Cloud GCP starters to trigger it. Not seeing FileNotFoundException can also mean that nothing is using this property.

kamalhm commented 3 years ago

here are all my included dependencies

    implementation 'com.google.cloud:spring-cloud-gcp-starter'
    implementation platform('com.google.cloud:libraries-bom:22.0.0')
    implementation 'com.google.cloud:google-cloud-kms'

i'm using springboot 2.5.4

Not seeing FileNotFoundException can also mean that nothing is using this property.

when I try to put the wrong filename, it detects that the file was not found

meltsufin commented 3 years ago

Which beans are you using? You probably need google-cloud-starter-kms to actually get any auto-configured beans. Also, sample code that reproduces the issue would be useful in debugging.

kamalhm commented 2 years ago

my bad, it works fine if I use full path, not sure why I couldn't get classpath to work