Java--Action: Consider defining a bean of type ‘com.XX.dao.XXDao‘ in your configuration

朴灿烈づ我的快乐病毒、 2023-10-05 15:57 117阅读 0赞

启动 SpringBoot项目报错:

  1. ***************************
  2. APPLICATION FAILED TO START
  3. ***************************
  4. Description:
  5. Field adminRoleRelationDao in com.macro.mall.tiny.service.impl.UmsAdminServiceImpl required a bean of type 'com.macro.mall.tiny.dao.UmsAdminRoleRelationDao' that could not be found.
  6. The injection point has the following annotations:
  7. - @org.springframework.beans.factory.annotation.Autowired(required=true)
  8. Action:
  9. Consider defining a bean of type 'com.macro.mall.tiny.dao.UmsAdminRoleRelationDao' in your configuration.

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L01pbmdnZVFpbmdjaHVu_size_16_color_FFFFFF_t_70

报错原因:

项目未扫描到 dao 包

解决办法:

在主启动类上加上:@ComponentScan(basePackages = {“com.XX.dao”}) 你的项目的dao层包路径,如下:

  1. @ComponentScan(basePackages = {"com.xx.dao"})//引入dao根路径
  2. //@MapperScan("com.macro.mall.tiny.mbg.mapper")
  3. @SpringBootApplication
  4. public class MallApplication {
  5. public static void main(String[] args) {
  6. SpringApplication.run(MallApplication.class, args);
  7. }
  8. }

发表评论

表情:
评论列表 (有 0 条评论,117人围观)

还没有评论,来说两句吧...

相关阅读