当前位置:   article > 正文

错误之处(三)

no qualifying bean of type 'com.mongodb.client.mongoclient

配置类的报错:

Could not autowire. No beans of 'MongoClient' type found.

这是 MongoDB 的配置类(JavaConfig)

  1. package com.xuecheng.manage_cms.config;
  2. import com.mongodb.client.MongoClient;
  3. import com.mongodb.client.MongoDatabase;
  4. import com.mongodb.client.gridfs.GridFSBucket;
  5. import com.mongodb.client.gridfs.GridFSBuckets;
  6. import org.springframework.beans.factory.annotation.Value;
  7. import org.springframework.context.annotation.Bean;
  8. import org.springframework.context.annotation.Configuration;
  9. /**
  10. * Created by 16114 on 2019/6/8.
  11. */
  12. @Configuration
  13. public class MongoConfig {
  14. @Value("${spring.data.mongodb.database}")
  15. String db;
  16. @Bean
  17. public GridFSBucket getGridFSBucket(MongoClient mongoClient){ //Could not autowire. No beans of 'MongoClient' type found.
  18. MongoDatabase database = mongoClient.getDatabase(db);
  19. GridFSBucket bucket = GridFSBuckets.create(database);
  20. return bucket;
  21. }
  22. }

1184092-20190608123124589-1090338389.png

这是测试类

  1. package com.xuecheng.manage_cms;
  2. import com.mongodb.client.gridfs.GridFSBucket;
  3. import com.mongodb.client.gridfs.GridFSDownloadStream;
  4. import com.mongodb.client.gridfs.model.GridFSFile;
  5. import org.apache.commons.io.IOUtils;
  6. import org.bson.types.ObjectId;
  7. import org.junit.Test;
  8. import org.junit.runner.RunWith;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.boot.test.context.SpringBootTest;
  11. import org.springframework.data.mongodb.core.query.Criteria;
  12. import org.springframework.data.mongodb.core.query.Query;
  13. import org.springframework.data.mongodb.gridfs.GridFsResource;
  14. import org.springframework.data.mongodb.gridfs.GridFsTemplate;
  15. import org.springframework.test.context.junit4.SpringRunner;
  16. import java.io.File;
  17. import java.io.FileInputStream;
  18. import java.io.FileNotFoundException;
  19. import java.io.IOException;
  20. /**
  21. * Created by 16114 on 2019/6/7.
  22. */
  23. @SpringBootTest
  24. @RunWith(SpringRunner.class)
  25. public class GridFsTest {
  26. @Autowired
  27. GridFsTemplate gridFsTemplate;
  28. @Autowired
  29. GridFSBucket gridFSBucket;
  30. @Test
  31. public void testGridFsTemplate() throws FileNotFoundException {
  32. File file = new File("d:/index_banner.ftl");
  33. FileInputStream fileInputStream = new FileInputStream(file);
  34. ObjectId objectId = gridFsTemplate.store(fileInputStream, "index_banner.ftl");
  35. System.out.println(objectId);
  36. }
  37. @Test
  38. public void queryFile() throws IOException {
  39. String fileId = "5cfb2520fd9fe107c887ee61";
  40. //根据id查询文件
  41. GridFSFile gridFSFile =
  42. gridFsTemplate.findOne(Query.query(Criteria.where("_id").is(fileId)));
  43. //打开下载流对象
  44. GridFSDownloadStream gridFSDownloadStream =
  45. gridFSBucket.openDownloadStream(gridFSFile.getObjectId());
  46. //创建gridFsResource,用于获取流对象
  47. GridFsResource gridFsResource = new GridFsResource(gridFSFile,gridFSDownloadStream);
  48. //获取流中的数据
  49. String s = IOUtils.toString(gridFsResource.getInputStream(), "UTF-8");
  50. System.out.println(s);
  51. }
  52. //删除文件
  53. @Test
  54. public void testDelFile() throws IOException {
  55. //根据文件id删除fs.files和fs.chunks中的记录
  56. gridFsTemplate.delete(Query.query(Criteria.where("_id").is("5cfb2520fd9fe107c887ee61")));
  57. }
  58. }

运行测试类的报错信息

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.mongodb.client.MongoClient' available: expected at least 1 bean which qualifies as autowire 
  1. Exclusions:
  2. -----------
  3. org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
  4. Unconditional classes:
  5. ----------------------
  6. org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration
  7. org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
  8. org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
  9. 2019-06-08 12:34:46.275 [main] DEBUG o.s.b.d.LoggingFailureAnalysisReporter - Application failed to start due to an exception
  10. org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.mongodb.client.MongoClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
  11. at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1655)
  12. at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1214)
  13. at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1168)
  14. at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
  15. at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
  16. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
  17. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
  18. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
  19. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
  20. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
  21. at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
  22. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  23. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
  24. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
  25. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:843)
  26. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
  27. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
  28. at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
  29. at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
  30. at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
  31. at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:127)
  32. at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
  33. at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
  34. at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
  35. at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
  36. at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
  37. at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
  38. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
  39. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
  40. at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  41. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
  42. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
  43. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
  44. at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  45. at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  46. at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  47. at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  48. at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  49. at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  50. at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
  51. at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  52. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
  53. at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  54. at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
  55. at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
  56. at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
  57. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  58. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  59. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  60. at java.lang.reflect.Method.invoke(Method.java:498)
  61. at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  62. 2019-06-08 12:34:46.278 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter -
  63. ***************************
  64. APPLICATION FAILED TO START
  65. ***************************
  66. Description:
  67. Parameter 0 of method getGridFSBucket in com.xuecheng.manage_cms.config.MongoConfig required a bean of type 'com.mongodb.client.MongoClient' that could not be found.
  68. Action:
  69. Consider defining a bean of type 'com.mongodb.client.MongoClient' in your configuration.
  70. 2019-06-08 12:34:46.281 [main] ERROR o.s.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@9597028] to prepare test instance [com.xuecheng.manage_cms.GridFsTest@6af5b246]
  71. java.lang.IllegalStateException: Failed to load ApplicationContext
  72. at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
  73. at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
  74. at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
  75. at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
  76. at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
  77. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
  78. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
  79. at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  80. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
  81. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
  82. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
  83. at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  84. at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  85. at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  86. at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  87. at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  88. at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  89. at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
  90. at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  91. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
  92. at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  93. at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
  94. at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
  95. at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
  96. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  97. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  98. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  99. at java.lang.reflect.Method.invoke(Method.java:498)
  100. at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  101. Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'getGridFSBucket' defined in class path resource [com/xuecheng/manage_cms/config/MongoConfig.class]: Unsatisfied dependency expressed through method 'getGridFSBucket' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.mongodb.client.MongoClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
  102. at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769)
  103. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
  104. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
  105. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
  106. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
  107. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
  108. at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
  109. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  110. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
  111. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
  112. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:843)
  113. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
  114. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
  115. at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
  116. at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
  117. at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
  118. at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:127)
  119. at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
  120. at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
  121. ... 28 common frames omitted
  122. Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.mongodb.client.MongoClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
  123. at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1655)
  124. at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1214)
  125. at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1168)
  126. at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
  127. at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
  128. ... 46 common frames omitted
  129. java.lang.IllegalStateException: Failed to load ApplicationContext
  130. at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
  131. at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
  132. at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
  133. at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
  134. at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
  135. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
  136. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
  137. at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  138. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
  139. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
  140. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
  141. at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  142. at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  143. at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  144. at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  145. at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  146. at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  147. at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
  148. at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  149. at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
  150. at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  151. at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
  152. at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
  153. at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
  154. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  155. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  156. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  157. at java.lang.reflect.Method.invoke(Method.java:498)
  158. at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  159. Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'getGridFSBucket' defined in class path resource [com/xuecheng/manage_cms/config/MongoConfig.class]: Unsatisfied dependency expressed through method 'getGridFSBucket' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.mongodb.client.MongoClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
  160. at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769)
  161. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
  162. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
  163. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
  164. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
  165. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
  166. at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
  167. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  168. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
  169. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
  170. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:843)
  171. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
  172. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
  173. at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
  174. at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
  175. at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
  176. at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:127)
  177. at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
  178. at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
  179. ... 28 more
  180. Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.mongodb.client.MongoClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
  181. at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1655)
  182. at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1214)
  183. at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1168)
  184. at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
  185. at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
  186. ... 46 more
  187. Process finished with exit code -1

转载于:https://www.cnblogs.com/Roni-i/p/10990419.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/220875
推荐阅读
相关标签
  

闽ICP备14008679号