admin管理员组文章数量:1794759
springBoot项目Consider defining a bean of type 'xxx' in your configuration错误的解决
我用IDEA创建一个springBoot项目,各种配置,mapper类和model类都检查了没有错,运行后控制台报错:
Field userMapper in com.ajax.service.J1902UserService required a bean of type ‘com.ajax.dao.J1902UserMapper’ 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.zym_ajax.dao.J1902UserMapper’ in your configuration.
就是说我的dao类没有注入成功,我就在网上查了一下,是项目的启动类没有Mapper扫描包的注解。
类上加注解@MapperScan指明Mapper类所在包的位置供SpringBoot扫描就好啦。
@SpringBootApplication @MapperScan("com.zym_ajax.dao") public class ZymAjaxApplication { public static void main(String[] args) { SpringApplication.run(ZymAjaxApplication.class, args); } }本文标签: 错误项目beandefiningSpringBoot
版权声明:本文标题:springBoot项目Consider defining a bean of type 'xxx' in your configuration错误的解决 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686551905a80976.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论