Other Services
Last updated
Was this helpful?
Last updated
Was this helpful?
Spring Cloud GCP has idiomatic integrations and starters for a number of Google Cloud services, but not all services. There may be cases where you need to use a Google Cloud client library directly. In this case, you can re-use basic bootstrapping provided by the Spring Cloud GCP, so you can have a consistent way of specifying credentials for your application.
Spring Cloud GCP already imports the , and it already has encoded the client library versions. So you can specify any Google Cloud client library without explicitly specifying a version. This is great to ensure that you are using a compatible version of a Google Cloud client library.
For example, to add Container Analysis client library:
You need Google Cloud credentials to access any services. produces a CredentailsProvider
bean so you can re-use the same credentials.
Usually you only need a singleton instance of the client library, so it makes sense to configuring it as a Spring Bean. Most client libraries needs to be shutdown gracefully, so you should specify the destroyMethod
as well:
In rare cases, you may want to know which Project ID you are currently configured to use by default. You can find out from the .