Skip to content
Branch: master
Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Add logging configuration for tests and set level to INFO (#1783) Jul 30, 2019
pom.xml Updated more versions to be parametrized (#1818) Aug 14, 2019


Spring GCP Cloud Vision Sample Application

This code sample shows how the Spring Cloud GCP integrations can simplify the use of Google Cloud Vision APIs.

It uses the Google Cloud Vision API to extract information about a picture. We take advantage of the GCP Support starter to retrieve the GCP credentials that we will use to authenticate with the API.

Running the sample

  1. Create a Google Cloud Platform project with billing enabled, if you don’t have one already.

  2. Enable the Google Cloud Vision API from the "APIs & Services" menu of the Google Cloud Console.

  3. Authenticate in one of two ways:

    1. Use the Google Cloud SDK to authenticate with application default credentials.

    2. Create a new service account, download its private key and point the property to it.

      Such as:

  4. Run the $ mvn spring-boot:run command from the same directory as this sample’s pom.xml file.

  5. Go to http://localhost:8080 in your browser, paste a URL to an image and press the Submit button.

  6. You will see a readable version of the Google Cloud Vision API response, which contains the words that Google Cloud Vision attributed to your image, as well as a percentage of certainty.

In this case, by using the Spring Cloud GCP Core Boot starter, you can inject a CredentialsProvider object which you can pass to our API to provide the correct Google credentials. You don’t need to set any environment variables for authentication to work.

You can’t perform that action at this time.