@SpringBootApplication public class Application extends Object
Constructor and Description |
---|
Application() |
Modifier and Type | Method and Description |
---|---|
com.google.cloud.vision.v1.ImageAnnotatorClient |
imageAnnotatorClient(com.google.api.gax.core.CredentialsProvider credentialsProvider)
Configure the Cloud Vision API client
ImageAnnotatorClient . |
static void |
main(String[] args) |
public static void main(String[] args)
@Bean public com.google.cloud.vision.v1.ImageAnnotatorClient imageAnnotatorClient(com.google.api.gax.core.CredentialsProvider credentialsProvider) throws IOException
ImageAnnotatorClient
. The
spring-cloud-gcp-starter autowires a CredentialsProvider
object that provides
the GCP credentials, required to authenticate and authorize Vision API calls.
Cloud Vision API client implements AutoCloseable
, which is automatically
honored by Spring bean lifecycle.
Most of the Google Cloud API clients are thread-safe heavy objects. I.e., it's better to produce a singleton and re-using the client object for multiple requests.
credentialsProvider
- GCP Credential to use to access Cloud Vision APIIOException
- if an exception occurs creating the ImageAnnotatorClientCopyright © 2018 Pivotal Software, Inc.. All rights reserved.