【发布时间】:2017-12-20 22:44:29
【问题描述】:
在上下文初始化期间遇到异常 - 取消刷新尝试:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“rabbitMqController”的bean时出错:通过字段“recordsReprositry”表示不满足的依赖关系;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有“com.rabbitmq.config.RecordsReprositry”类型的合格 bean 可用:预计至少有 1 个有资格作为自动装配候选者的 bean。依赖注解:{@org.springframework.beans.factory.annotation.Autowired(required=true)}
【问题讨论】:
-
请展示您定义存储库的方式。堆栈跟踪不足以帮助您
-
包 com.rabbitmq.config;导入 java.util.UUID;导入 org.springframework.data.repository.CrudRepository;导入 org.springframework.stereotype.Repository; @Repository public interface RecordsReprositry extends CrudRepository
{ public Records findById(UUID id); } -
您可以编辑您的问题以提供更多信息。将控制器和存储库代码粘贴到那里
-
这些是带有自动装配和请求映射的注释 @RestController public class RabbitMqController { Autowired private RecordsReprositry recordsReprositry; RequestMapping(name="/btsocr", method=RequestMethod.GET) public String btsOCR() throws Exception { return "Working"; } }
-
为什么要在别人的包命名空间中定义 bean?
标签: java spring spring-data