本文主要是介绍Springboot项目启动失败提示找不到dao类的解决,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
《Springboot项目启动失败提示找不到dao类的解决》SpringBoot启动失败,因ProductServiceImpl未正确注入ProductDao,原因:Dao未注册为Bean,解决:在启...
***************************
APPLICAChina编程TION FAILChina编程ED TO START
***************************Description:
Field productDao in com.yj.inventorymanagement.service.impl.ProductServiceImpl required a bean of type 'com.yj.inventorymanagement.dao.ProductDao' that couandroidld not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Aphputowired(required=true)Action:
Consider defining a bean of type 'com.yj.inventorymanagement.dao.ProductDao' in your configuration.
错误描述
项目里明明已经写了dao类,却还是提示xxxDao类notFound。
原因
没有注入dao类。
解决方法
可以在这个dao类上加上@Mapper注解,也可以在整个项目的启动类xxxApplication加上@MapperScan(basePackages="dao类所在的包路径"),推荐第二种方式注入dao,因为项目的dao类不止一个,这样就不用一个一个dao文件去加@Mapper,可以做到一劳永逸。
@SpringBootApplication @MapperScan(basePackagepythons = "com.yj.inventorymanagement.dao") public class InventoryManagementApplication { public static void main(String[] args) { SpringApplication.run(InventoryManagementApplication.class, args); } }
总结
这篇关于Springboot项目启动失败提示找不到dao类的解决的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!