We’re excited to announce that Spring Cloud GCP version 4.0 is now generally available! In this post, we’ll be describing what the new major version has to offer, and demonstrating the process of using the migration guide on one of our reference architectures, Bank of Anthos.
What’s new?
With this release, Spring Cloud GCP officially supports Spring Boot 3.x. However, this migration involves a number of breaking changes as outlined in the migration guide. The full list of changes made is available on Github, but the one of the most significant differences is that Java 17 is now a minimum requirement.
Another notable feature of this release is the addition of starter artifacts – Spring Boot starters for Google Cloud – that provide dependencies and auto-configurations for 80+ Google Client libraries. Just as the name suggests, these starters can serve as helpful starting points when working with a new client library. For now, they’re in preview.
These starters are not included in the BOM by default and need to be added as a dependency to your project before they can be used. For example, if you wanted to get started with Cloud Text-to-Speech, you would include the following:
The upgrade process
We prepared a migration guide to help answer any questions involved with moving from 3.x to 4.x. Let’s follow those instructions to migrate Bank of Anthos.
We’ll start by cloning and building the application before the upgrade, according to the quickstart and development guide:
At the end of this, you should see a “deployment stabilized” message:
With the environment set up for development, we’re ready to move on to the actual migration. The migration is already complete at time of writing, but here’s the full list of changes made:
We began by checking the current Java, Spring Boot and Spring Cloud GCP versions.
Our Java version is okay, but the other two are out of date, and will need to be updated.
We can also add the Spring Cloud GCP BOM to manage our versions going forward while we’re here.
Then, in no particular order, we can make the following code changes:
Remove the explicit type declarations from our ResponseEntity instantiations.
Replace all javax.* imports with Jakarta.* counterparts, since Spring 3.0 makes use of Jakarta EE 9.0
With those changes in place, the app is upgraded and ready to re-deploy!
Live example
For a finished example of this migration, check out the Bank of Anthos repository on Github. It’s an excellent sample application that showcases a polyglot Java & Python app, served on Kubernetes and Google Cloud. All CI/CD and configurations are open source, so it may be instructive as you approach this migration.
Thanks for reading, and feel free to provide comments or feedback on Twitter, or in the issues section of the repository.
Cloud BlogRead More