问题说明:
在注入OSSClient报错,找不到bean
报错信息
1:required a bean of type ‘com.aliyun.oss.OSSClient’ that could not be found.
2:如果遇到@org.springframework.beans.factory.annotation.Autowired(required=true)也可以采用如下思路解决
问题到源码之路
使用:
报错如图:
原因说明:
从自动配置入手,查看源码-如图
1查找文件
2查看配置
3发现是接口
得到解决方案
我们不是使用实现类型,要使用接口类型
采用
@Autowired
OSS ossClient;