Spring Boot应用程序无法启动并显示错误

时间:2019-02-13 13:56:49

标签: spring spring-boot

我有以下存储库

 @Repository
 public interface QuestionRepository extends JpaRepository<Question, 
    Long> {
     }

并且我尝试如下图所示在控制器中自动装配该存储库,但我看到此错误

@RestController
public class QuestionController {

    @Autowired
    private QuestionRepository questionRepository;


    @GetMapping("/questions")
    public Page<Question> getQuestions(Pageable pageable) {
     return questionRepository.findAll(pageable);
    }
}
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'questionController': Unsatisfied dependency expressed through field 'questionRepository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.kfz24.mockingservice.repository.QuestionRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

0 个答案:

没有答案