解决: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 ...
随机推荐
- 【 Hibernate 】Hibernate的session更新和删除失败问题
applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xm ...
- GIL/Copy/私有/面向对象
1. GIL Python语言和GIL没有关系.仅仅是由于历史原因在Cpython虚拟机(解释器),难以移除GIL. GIL:全局解释器锁.每个线程在执行的过程都需要先获取GIL,保证同一时刻只有一个 ...
- Linux list_head
在linux kernel里面链表应用非常广泛. 我们在应用程序中,定义一个链表结构通常要包含数据域,如下: typedef struct _listNode{ int data; struct _l ...
- JavaScript对象,函数,作用域
JavaScript对象 在 JavaScript中,几乎所有的事物都是对象.JavaScript 对象是拥有属性和方法的数据. var car = {type:"Fiat", m ...
- 查看Oracle的表中有哪些索引(用user_indexes和user_ind_columns)
用user_indexes和user_ind_columns系统表查看已经存在的索引 对于系统中已经存在的索引我们可以通过以下的两个系统视图(user_indexes和user_ind_columns ...
- Spring IoC(三)bean属性、方法注释
1.环境配置 使用注解开发jdk1.5.Spring2.5支持,在xml中添加context相关的是四个配置; <beans default-lazy-init="true" ...
- HTML使用链接调用本地exe文件
一,win+r打开注册表,输入regedit进入注册表 二,在注册表左边最上面HKEY_CLASSES_ROOT那个树右键新建项.该项的名称自己命名,其实该名称也是协议的名称. 我们调用的时候就是根据 ...
- jmeter beanshell 使用参数引用
1.直接使用beanshell 写代码引用: 2. beanshell 引用.java 文件 3.beanshell 引用jar 包
- js 判断素数(质数)
判断一个数是不是素数 function isPrinme(n) { if(n == 0 || n==1){ return false; } if(n==2){ return true; } for(v ...
- Computational Complexity of Fibonacci Sequence / 斐波那契数列的时空复杂度
Fibonacci Sequence 维基百科 \(F(n) = F(n-1)+F(n-2)\),其中 \(F(0)=0, F(1)=1\),即该数列由 0 和 1 开始,之后的数字由相邻的前两项相加 ...