本文主要是介绍Java--Action: Consider defining a bean of type ‘com.XX.dao.XXDao‘ in your configuration,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
启动 SpringBoot项目报错:
***************************
APPLICATION FAILED TO START
***************************Description: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.The injection point has the following annotations:- @org.springframework.beans.factory.annotation.Autowired(required=true)Action:Consider defining a bean of type 'com.macro.mall.tiny.dao.UmsAdminRoleRelationDao' in your configuration.
报错原因:
项目未扫描到 dao 包
解决办法:
在主启动类上加上:@ComponentScan(basePackages = {“com.XX.dao”}) 你的项目的dao层包路径,如下:
@ComponentScan(basePackages = {"com.xx.dao"})//引入dao根路径
//@MapperScan("com.macro.mall.tiny.mbg.mapper")
@SpringBootApplication
public class MallApplication {public static void main(String[] args) {SpringApplication.run(MallApplication.class, args);}
}
这篇关于Java--Action: Consider defining a bean of type ‘com.XX.dao.XXDao‘ in your configuration的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!