zoukankan      html  css  js  c++  java
  • SpringBoot集成spring-data-jpa注入Bean失败

    当项目结构正常(spring管理的Bean在SrpingBoot启动类平级或下级,支持spring扫描时),实现类上加 @Service注解,在实现类中注入dao层的Bean时,项目无法启动,无法找到注入dao层的Bean,会报如下错:

    Description:
    Field businessInfoBelongRepository in com.example.test.service.impl.QueryHouseListImpl required a bean of type 'com.example.test.repository.BusinessInfoBelongRepository' that could not be found.

     Action:

     Consider defining a bean of type 'com.example.test.repository.BusinessInfoBelongRepository' in your configuration.

    解决办法:pom文件中需要引入spring-data-jpa的的Maven包

     <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-data-jpa</artifactId>
     </dependency>

    总结:SpringDataJPA内部使用了类代理的方式让继承了(JpaRepository)它接口的子接口都以spring管理的Bean的形式存在,当你没有引用spring-data-jpa的时,则在实现类中注入dao层Bean会提示dao层的bean无法注入

  • 相关阅读:
    android 多线程
    android调用 .net webService
    android apk程序升级
    android连数据库
    android事件
    android 服务
    android 活动
    (12)android控件-Advanced
    (11)android控件-Transitions
    (10) android控件-date
  • 原文地址:https://www.cnblogs.com/dashuaiguo/p/10506956.html
Copyright © 2011-2022 走看看