【发布时间】:2020-05-24 16:00:01
【问题描述】:
我正在尝试将 spring 库用于谷歌云 API:
spring-cloud-gcp-starter-vision
但是 Spring Application Context 加载失败并报错:
原因:org.springframework.beans.factory.UnsatisfiedDependencyException:在类路径资源 [org/springframework/cloud/gcp/autoconfigure/vision/CloudVisionAutoConfiguration$VisionOcrConfiguration.class] 中定义名称为“documentOcrTemplate”的 bean 创建错误:不满意通过方法 'documentOcrTemplate' 参数 1 表达的依赖关系;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有“com.google.cloud.storage.Storage”类型的合格 bean 可用:预计至少有 1 个有资格作为自动装配候选者的 bean。依赖注释:{}...
我不知道如何处理它,因为它都是谷歌的代码,在我自己的代码中没有。
仅供参考,这是我尝试使用此库的方式:
@Service
public class OCRServiceImpl implements OCRService {
private static Log LOGGER = LogFactory.getLog(OCRServiceImpl.class);
@Autowired
private CloudVisionTemplate cloudVisionTemplate;
@Autowired
private ResourceLoader resourceLoader;
【问题讨论】:
-
奇怪的是,它在本地工作,一旦放在 GCP 中的容器上抛出 UnsatisfiedDependencyException,我检查了 CloudVisionTemplate 的构造函数,它有 ImageAnnotatorClient。扫描这个包裹怎么样?
标签: spring-boot google-cloud-platform google-cloud-storage spring-cloud-gcp