There is no GoogleCloudClient class in Spring Boot or in Google's libraries. It is a name that tutorials and projects use for a hand-written wrapper around Google Cloud clients. In current Spring Boot applications you rarely need one, because Spring Cloud GCP auto-configures the clients as beans and handles credentials and the project ID for you.
This article explains what such a wrapper is meant to do, why the usual implementation is a poor pattern, and how to get the same result with Spring Cloud GCP.
A custom GoogleCloudClient class usually tries to centralize three things: credentials, project configuration and access to services such as Cloud Storage, Pub/Sub and Firestore. The goal is reasonable. The execution in many examples is not:
src/main/resources, which puts a secret into source control and into the built jar.@Configuration but exposes plain methods instead of @Bean methods, so Spring never manages the lifecycle.IOException for credential loading.Google Cloud libraries use Application Default Credentials (ADC). The client finds credentials in this order: the file named by the GOOGLE_APPLICATION_CREDENTIALS environment variable, credentials from gcloud auth application-default login during local development, and the attached service account when running on Google Cloud (Cloud Run, GKE with Workload Identity, Compute Engine).
On Google Cloud you should not ship a key file at all. Attach a service account to the workload and grant it only the roles it needs, such as roles/storage.objectAdmin on one bucket. Service account keys are long-lived secrets; avoid them where a platform identity is available.
Spring Cloud GCP is the supported integration. It provides starters that auto-configure a credentials provider, a project ID provider and the service clients. Import its BOM, then add the starters you need.
Pick the spring-cloud-gcp.version that matches your Spring Boot line from the Spring Cloud GCP release notes; the versions are tied to Spring Boot generations. Then set the few properties you need:
When the project ID is not set, Spring Cloud GCP tries to read it from the environment or from the metadata server.
With the starters present, Storage and PubSubTemplate are ordinary Spring beans. No wrapper is required.
The returned future completes with the Pub/Sub message ID. Use constructor injection rather than @Autowired fields so the services are easy to test with a mocked Storage.
A wrapper is useful when you want a stable boundary of your own, for example an ObjectStore interface with put and get methods that hides Cloud Storage from the rest of the code. Write it as a normal service that receives the auto-configured clients, not as a class that creates them. That keeps credentials, retries and timeouts in configuration, and lets you swap the implementation in tests or for another provider.
If you must build a client by hand, create it once as a @Bean:
getDefaultInstance() uses ADC and the default project, so no key file is read in application code.
No. Neither Spring Boot nor the Google Cloud client libraries define a class with that name. It is a naming convention for custom wrappers.
No. Use Application Default Credentials, an attached service account or Workload Identity. Keep any key file outside the repository and the jar.
No. Cloud clients are thread-safe and designed to be shared. Create them once as beans.
Auto-configuration, credentials and project ID resolution, PubSubTemplate, gs:// resource support and Spring Boot integration such as health and tracing support.
GoogleCloudClient is not a framework class. Replace hand-built wrappers with Spring Cloud GCP starters, rely on Application Default Credentials instead of bundled key files, and inject the Storage and PubSubTemplate beans directly. Add your own thin interface only when you want a boundary around the cloud provider.