报错信息
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'WebGatherService':
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: private cn.xo68.boot.webgather.repository.WebGatherRepository ;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type [cn.xo68.boot.webgather.repository.WebGatherRepository] found for dependency:
expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
解决方案
在配置类上添加mongodb的仓储类包注解
@Configuration
@EnableMongoRepositories(basePackages = {"cn.xo68.boot.webgather.repository"})
@EntityScan({"cn.xo68.boot.webgather.document"})
public class WebConfig {
}