@Configuration(proxyBeanMethods=false) @EnableConfigurationProperties(value=CloudVisionProperties.class) @ConditionalOnClass(value=CloudVisionTemplate.class) @ConditionalOnProperty(value="spring.cloud.gcp.vision.enabled", matchIfMissing=true) public class CloudVisionAutoConfiguration extends Object
Constructor and Description |
---|
CloudVisionAutoConfiguration(CloudVisionProperties properties,
com.google.api.gax.core.CredentialsProvider credentialsProvider) |
Modifier and Type | Method and Description |
---|---|
Executor |
cloudVisionExecutor() |
CloudVisionTemplate |
cloudVisionTemplate(ImageAnnotatorClient imageAnnotatorClient) |
ImageAnnotatorClient |
imageAnnotatorClient()
Configure the Cloud Vision API client
ImageAnnotatorClient . |
public CloudVisionAutoConfiguration(CloudVisionProperties properties, com.google.api.gax.core.CredentialsProvider credentialsProvider) throws IOException
IOException
@Bean @ConditionalOnMissingBean public ImageAnnotatorClient imageAnnotatorClient() 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.
IOException
- if an exception occurs creating the ImageAnnotatorClient@Bean @ConditionalOnMissingBean public CloudVisionTemplate cloudVisionTemplate(ImageAnnotatorClient imageAnnotatorClient)
@Bean @ConditionalOnMissingBean(name="cloudVisionExecutor") public Executor cloudVisionExecutor()
Copyright © 2021. All rights reserved.