Get ahead
VMware offers training and certification to turbo-charge your progress.
Learn moreDear Spring Community!
The Spring Cloud GCP is a set of Spring Boot starters that is designed to help you leverage Google Cloud Platform managed services directly from Spring Boot, allowing you to use Spring Messaging for Cloud Pub/Sub, Spring Resource for Cloud Storage, Spring Cloud Sleuth for Stackdriver Trace, Spring Data with Cloud SQL, and more.
We’ve just released Spring Cloud GCP 1.0.0.M3
. Check out what’s new since the previous Milestone 2!
Spring Cloud GCP 1.0.0.M3
is now up to date to work with Spring Boot 2.0.1.RELEASE
and Spring Cloud Finchley.M9
.
To use Spring Cloud GCP 1.0.0.M3
, simply import the BOM in your Spring Boot 2.0
project:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>1.0.0.M3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
You can now find Spring Cloud GCP in the Spring Initializr! Head to http://start.spring.io/ and look for "GCP" related starters.
For example, to use Cloud Pub/Sub for messaging, simply add the GCP Messaging dependencies in the Initializr. This starter also contains the Spring Integration channel adapters, as well as the Spring Cloud Stream Pub/Sub binder.
Currently, only the base support, messaging, and storage are in the Initializr menu. Refer to the Spring Cloud GCP Reference documentation to add other starters. We are working to add more to Initializr.
You can now build multi-regional Spring Boot applications backed by Google Cloud Spanner - a globally-distributed, strongly consistent, relational database. With Spring Data Spanner, you can now annotate your POJOs for object mapping to Spanner tables. It supports:
Spanner Transactions
Paging and Sorting Repository
REST Repository
Query by method name convention, annotation, and named queries!
@Table(name = "traders") public class Trader { @PrimaryKey @Column(name = "trader_id") String traderId;
String firstName;
String lastName;
}
public interface TraderRepository extends PagingAndSortingRepository<Trader, String> { }
If you are using Pivotal Cloud Foundry and the Google Cloud Platform Service Broker, Spring Boot GCP Starters can automatically consume GCP Service Broker bindings and credentials to configure your application. The following services are supported:
Cloud Storage
Cloud Pub/Sub
Cloud Spanner
Stackdriver Trace
If you are not familiar with Spring Boot on Cloud Foundry, checkout the Spring Boot Cloud Foundry Deployment documentation.
For example, you can provision and bind Stackdriver Trace service credentials via the Service Broker:
$ cf create-service google-stackdriver-trace default mytrace $ cf bind-service myapp mytrace
In your application, add the Spring Cloud GCP Trace starter:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-trace</artifactId>
</dependency>
When you deploy your application into PCF with this service binding, the starter will automatically read the configuration from the VCAP_SERVICES
environment variable. The Spring Cloud Trace starter will automatically forward distributed trace data to Stackdriver Trace.
$ cf push myapp -p path/to/my.jar
Stackdriver Trace is part of Stackdriver Application Performance Management (APM) tools. Learn more from the Stackdriver APM announcement blog.
Check out the code samples in the Spring Cloud GCP GitHub repository, read the Spring Cloud GCP Reference documentation for more details, and try it hands on with code labs. Most importantly, let us know your feedback and report any issues.
From the Spring Cloud GCP Team