Getting Started
This section describes how to get up to speed with Spring Framework on Google Cloud libraries.
Compatibility with Spring Project Versions
Spring Framework on Google Cloud has dependency and transitive dependencies on Spring Projects. The table below outlines the versions of Spring Cloud, Spring Boot and Spring Framework versions that are compatible with certain Spring Framework on Google Cloud version.
Spring Framework on Google Cloud | Spring Cloud | Spring Boot | Spring Framework |
---|---|---|---|
2.x |
2020.0.x (3.0/Illford) |
2.4.x, 2.5.x |
5.3.x |
3.x |
2021.0.x (3.1/Jubilee) |
2.6.x, 2.7.x |
5.3.x |
4.x |
2022.0.x (4.0/Kilburn) |
3.0.x,3.1.x |
6.0.x |
Setting up Dependencies
All Spring Framework on Google Cloud artifacts are made available through Maven Central. The following resources are provided to help you setup the libraries for your project:
-
Maven Bill of Materials for dependency management
-
Starter Dependencies for depending on Spring Framework on Google Cloud modules
You may also consult our Github project to examine the code or build directly from source.
Bill of Materials
The Spring Framework on Google Cloud Bill of Materials (BOM) contains the versions of all the dependencies it uses.
If you’re a Maven user, adding the following to your pom.xml file will allow you omit any Spring Framework on Google Cloud dependency version numbers from your configuration. Instead, the version of the BOM you’re using determines the versions of the used dependencies.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>4.8.5-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Or, if you’re a Gradle user:
dependencies {
implementation platform("com.google.cloud:spring-cloud-gcp-dependencies:4.8.5-SNAPSHOT")
}
In the following sections, it will be assumed you are using the Spring Framework on Google Cloud BOM and the dependency snippets will not contain versions.
Starter Dependencies
Spring Framework on Google Cloud offers starter dependencies through Maven to easily depend on different modules of the library. Each starter contains all the dependencies and transitive dependencies needed to begin using their corresponding Spring Framework on Google Cloud module.
For example, if you wish to write a Spring application with Cloud Pub/Sub, you would include the spring-cloud-gcp-starter-pubsub
dependency in your project.
You do not need to include the underlying spring-cloud-gcp-pubsub
dependency, because the starter
dependency includes it.
A summary of these artifacts are provided below.
Aside from these modules, we also provide additional starters with auto-configurations to various Google Client Libraries. Refer for the full list here.
Spring Framework on Google Cloud Starter | Description | Maven Artifact Name |
---|---|---|
Core |
Automatically configure authentication and Google project settings |
|
Cloud Spanner |
Provides integrations with Google Cloud Spanner |
|
Cloud Datastore |
Provides integrations with Google Cloud Datastore |
|
Cloud Pub/Sub |
Provides integrations with Google Cloud Pub/Sub |
|
Logging |
Enables Cloud Logging |
|
SQL - MySQL |
Cloud SQL integrations with MySQL |
|
SQL - PostgreSQL |
Cloud SQL integrations with PostgreSQL |
|
Storage |
Provides integrations with Google Cloud Storage and Spring Resource |
|
Config |
Enables usage of Google Runtime Configuration API as a Spring Cloud Config server |
|
Trace |
Enables instrumentation with Google Cloud Trace |
|
Vision |
Provides integrations with Google Cloud Vision |
|
Security - IAP |
Provides a security layer over applications deployed to Google Cloud |
|
Security - Firebase |
Provides a security layer over applications deployed to Firebase |
Spring Initializr
Spring Initializr is a tool which generates the scaffolding code for a new Spring Boot project. It handles the work of generating the Maven or Gradle build file so you do not have to manually add the dependencies yourself.
Spring Initializr offers three modules from Spring Framework on Google Cloud that you can use to generate your project.
-
GCP Support: The GCP Support module contains auto-configuration support for every Spring Framework on Google Cloud integration. Most of the autoconfiguration code is only enabled if the required dependency is added to your project.
-
GCP Messaging: Google Cloud Pub/Sub integrations work out of the box.
-
GCP Storage: Google Cloud Storage integrations work out of the box.
Learning Spring Framework on Google Cloud
There are a variety of resources to help you learn how to use Spring Framework on Google Cloud libraries.
Sample Applications
The easiest way to learn how to use Spring Framework on Google Cloud is to consult the sample applications on Github. Spring Framework on Google Cloud provides sample applications which demonstrate how to use every integration in the library. The table below highlights several samples of the most commonly used integrations in Spring Framework on Google Cloud.
Google Cloud Integration | Sample Application |
---|---|
Cloud Pub/Sub |
|
Cloud Spanner |
|
Datastore |
|
Cloud SQL (w/ MySQL) |
|
Cloud Storage |
|
Cloud Logging |
|
Trace |
|
Cloud Vision |
|
Cloud Security - IAP |
|
Cloud Security - Firebase |
Each sample application demonstrates how to use Spring Framework on Google Cloud libraries in context and how to setup the dependencies for the project. The applications are fully functional and can be deployed to Google Cloud as well. If you are interested, you may consult guides for deploying an application to AppEngine and to Google Kubernetes Engine.
Codelabs
For a more hands-on approach, there are several guides and codelabs to help you get up to speed. These guides provide step-by-step instructions for building an application using Spring Framework on Google Cloud.
Some examples include:
The full collection of Spring codelabs can be found on the Google Developer Codelabs page.