'com.mongodb.MongoClient' that could not be found?

来源:5-15 整合SpringBoot【GridFS】

慕莱坞4268960

2020-11-27

Parameter 0 of method getGridFSBucket in com.hanma.files.config.GridFSConfig required a bean of type ‘com.mongodb.MongoClient’ that could not be found.
你好老师,在运行的时候出现了这个问题,没有排查出什么原因?依赖也加入了,配置文件自己写完不行,又复制了文档里面的也不行,排查很长时间,不知道是什么原因

写回答

2回答

玛塔玛塔

2021-03-07

Hello, Eric,你的问题解决了吗,是怎么解决的?

0
1
慕莱坞4268960
我记得应该是解决了,好长时间了 以上还可以按照如下方案就行使用,如 去掉依赖: org.mongodb mongodb-driver 在article模块config层下创建GridFSConfig文件,如 @Configuration public class GridFsConfig { @Value("${spring.data.mongodb.database}") private String mongodb; //GridFSBucket用于打开下载流 @Bean public GridFSBucket getGridFSBucket(MongoClient mongoClient){ MongoDatabase database = mongoClient.getDatabase(mongodb); GridFSBucket bucket = GridFSBuckets.create(database); return bucket; } }
2021-03-16
共1条回复

风间影月

2020-11-27

看似是有个config没有注入mongo,也有可能是配置了,但是没有被扫描

0
0

Spring Cloud 进阶 Alibaba 微服务体系自媒体实战

一课收获分布式系统开发,微服务核心技术和中间件企业生产落地

1113 学习 · 896 问题

查看课程