1
votes

I am trying to use spring library for google cloud API:

spring-cloud-gcp-starter-vision

But Spring Application Context fails to load with an error:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'documentOcrTemplate' defined in class path resource [org/springframework/cloud/gcp/autoconfigure/vision/CloudVisionAutoConfiguration$VisionOcrConfiguration.class]: Unsatisfied dependency expressed through method 'documentOcrTemplate' parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.google.cloud.storage.Storage' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}...

I'm not sure how I can handle it since it's all google's code, nothing in my own code.

Just for the information, this is the way I'm trying to use this library:

@Service
public class OCRServiceImpl implements OCRService {

    private static Log LOGGER = LogFactory.getLog(OCRServiceImpl.class);

    @Autowired
    private CloudVisionTemplate cloudVisionTemplate;

    @Autowired
    private ResourceLoader resourceLoader;
2
it is weird the fact that on local it works, once put on a container in GCP throws UnsatisfiedDependencyException, i checked the constructor of CloudVisionTemplate and it has ImageAnnotatorClient. how about scanning this package ? - Tiago Medici

2 Answers

0
votes

Have you set spring.cloud.gcp.vision ?

@ConfigurationProperties("spring.cloud.gcp.vision")

and have a look @CloudVisionAutoConfiguration

    @Bean
    @ConditionalOnMissingBean
    public CloudVisionTemplate cloudVisionTemplate(ImageAnnotatorClient imageAnnotatorClient) {
        return new CloudVisionTemplate(imageAnnotatorClient);
    }

Looks like you are missing the properties configuration!!!

0
votes

You need to add both the spring-cloud-gcp-starter-vision and spring-cloud-gcp-starter-storage to your dependencies.

See cloud-vision-ocr-dependencies.