解决:Field xxMapper in xx.service.impl.xxServiceImpl required a bean of type 'xx.mapper.xxMapper'
1、启动 SpringBoot项目报错,使用的是Springboot、Spring、Mybatis连接Mysql数据库,启动SpringBoot项目报错,错误如下所示:
_____ .__/\ .__
_/ ____\____ |__)/__ __|__|____ ____
\ __\/ __ \| |\ \/ / \__ \ / \
| | \ ___/| | > <| |/ __ \| | \
|__| \___ >__|/__/\_ \__(____ /___| /
\/ \/ \/ \/ -- ::26.771 INFO --- [ main] c.f.n.NationalpolicyApplication : Starting NationalpolicyApplication on DESKTOP-T450s with PID (D:\biehl\idea\workspace\nationalpolicy2\target\classes started by Aiyufei in D:\biehl\idea\workspace\nationalpolicy2)
-- ::26.777 INFO --- [ main] c.f.n.NationalpolicyApplication : No active profile set, falling back to default profiles: default
-- ::28.302 INFO --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JDBC repositories in DEFAULT mode.
-- ::28.336 INFO --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 28ms. Found JDBC repository interfaces.
-- ::28.489 WARN --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.feixian.mapper]' package. Please check your configuration.
-- ::29.271 INFO --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): (http)
-- ::29.292 INFO --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
-- ::29.294 INFO --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.]
-- ::29.449 INFO --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
-- ::29.449 INFO --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in ms
-- ::29.521 WARN --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'repoPolicyContentController': Unsatisfied dependency expressed through field 'repoPolicyContentService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'repoPolicyContentServiceImpl': Unsatisfied dependency expressed through field 'repoPolicyContentMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.feixian.nationalpolicy.mapper.RepoPolicyContentMapper' available: expected at least bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
-- ::29.525 INFO --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
-- ::29.546 INFO --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
-- ::29.681 ERROR --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************
APPLICATION FAILED TO START
*************************** Description: Field repoPolicyContentMapper in com.feixian.nationalpolicy.service.impl.RepoPolicyContentServiceImpl required a bean of type 'com.feixian.nationalpolicy.mapper.RepoPolicyContentMapper' 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.feixian.nationalpolicy.mapper.RepoPolicyContentMapper' in your configuration. Process finished with exit code
2. 报错原因,是因为项目未扫描到 mapper 包。
3. 解决该报错的方法,如下所示:
在项目启动类上加注解 @MapperScan("Mapper文件所在的包"),@MapperScan 是扫描mapper类的注解,就不用在每个mapper类上加@MapperScan了。
4、重启工程成功运行。
解决:Field xxMapper in xx.service.impl.xxServiceImpl required a bean of type 'xx.mapper.xxMapper'的更多相关文章
- 运行springboot项目报错:Field userMapper in XX required a bean of type 'xx' that could not be found.
运行springboot项目报错: *************************** APPLICATION FAILED TO START ************************** ...
- Field userService in com.wuji.controller.UserController required a bean of type 'com.wuji.service.UserService' that could not be found
Field userService in com.wuji.controller.UserController required a bean of type 'com.wuji.service.Us ...
- 解决办法 Field userService in com.sxsj.controller.RegistLoginController required a bean of type
转自:https://blog.csdn.net/awmw74520/article/details/82687288 APPLICATION FAILED TO START Error starti ...
- Field tTypeMapper in com.atguigu.project.service.imp.projectInfoServiceImpl required a bean of type 'com.atguigu.project.mapper.TTypeMapper' that could not be found.
解决:MapperScan
- Field baseMapper in com.baomidou.mybatisplus.extension.service.impl.ServiceImpl required a single bean, but xx were found:
在学习使用 mybatis-plus 时,遇到一个奇怪的异常 如 代码一: 代码一: Error starting ApplicationContext. To display the conditi ...
- How to solve the error "Field service in com.xx.xxx.xxxx required a bean of type 'com.aa.bb.cc' that could not be found."
When runung a SpringBoot demo, I got a error as following: *************************** APPLICATION ...
- 2. springboot启动报错:Field userMapper in com.service.UserService required a bean of type 'com.dao.UserMapper' that could not be found.
报错信息: 2018-06-25 14:26:17.103 WARN 49752 --- [ restartedMain] ationConfigEmbeddedWebApplicationCon ...
- Consider defining a bean of type 'XX.XX.XX.XX.mapper.XXMapper' in your configuration.
今天构建一个springboot 项目,采用mybatis+mysql 然后就出现了这种错误....浪费我半天时间 Description: Field loginLogMapper in com.g ...
- springboot jpa mongodb 整合mysql Field in required a bean of type that could not be found Failed to load ApplicationContext
1.完整报错 *************************** APPLICATION FAILED TO START *************************** Descripti ...
随机推荐
- python 处理form/data文件上传
处理multipart/form-data 的java serverlet请求接口通过python实现 记住不要在头加:"Content-Type":"multipart ...
- Laravel 解决在ajax 请求下不能保存session的问题
Laravel 解决在ajax 请求下不能保存session的问题 \Session::put('isLogin',true); // 你要保存的session key \Session::put(' ...
- 基于JSP开发手机销售购物商城系统
开发环境: Windows操作系统开发工具:Eclipse+Jdk+Tomcat+MySQL数据库 运行效果图: 源码及原文链接:https://javadao.xyz/forum.php?mod=v ...
- Android Studio真机无线调试
条件 手机要和电脑处于同一局域网内(即都连同一个WiFi 或者电脑的网线另外一段连接到手机连接WiFi的路由上) 步骤 .首先将手机连接 WiFi 网络 .将手机用数据线与电脑连接,并且在电脑端 打开 ...
- 吴裕雄 PYTHON 人工智能——基于MASK_RCNN目标检测(5)
import os import sys import numpy as np import tensorflow as tf import matplotlib import matplotlib. ...
- 洛谷 P5016 龙虎斗(模拟)
嗯... 题目链接:https://www.luogu.org/problem/P5016 这道题是一道模拟,不要考虑复杂,直接暴力枚举每一个点,看看加上s2之后两个势力的差值,找最小,记录下标. 注 ...
- chrome 2行换行省略号 ... text-ellipse
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; 谷歌内部项目 ...
- buu Crypto 刷题记录
1.MD5 直接解. 2.url编码 直接解. 3.一眼就解密 base64. 4.看我回旋踢 对文本内容全部CaesarDecode. 5.摩丝 直接MorseDecode. 6.Quoted-pr ...
- 【代码审计】VAuditDemo 重装漏洞
一.源码安装漏洞介绍 一般在PHP源码程序都有一个初始安装的功能,如果相关代码没有对参数进行严格过滤,可能会导致攻击者访问安装页面(install.php)或构造数据包,对网站进行重新安装,从而危害网 ...
- 案例:WLC HA主WLC进入维护模式
案例场景: 如图所示,7609-1和7609-2分别是网络中的核心设备,起了HSRP,7609-1连接的是WLC-1,,7609-2连接的是WLC-2,WLC1和WLC2的RP口相互连接. WLC的管 ...