Error creating bean with name
最近在学一个东西,要使用SSM新建一个案例,是这样滴,我有如下
- DeptDAO
- DeptService
- DeptServiceImpl
- DeptController
- Dept
- Mybatis
首先,我不是太清楚有了DAO还要有Service,不过这个不是本文章的重点。
重点是,报如下错,两个不同的错误吧
错误1:
2019-04-02 22:09:08.697 ERROR 12080 --- [nio-8001-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.vae.springcloud.dao.DeptDAO.findAll] with root cause
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.vae.springcloud.dao.DeptDAO.findAll
错误2:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'deptController': Unsatisfied dependency expressed through field 'deptService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'deptServiceImpl': Unsatisfied dependency expressed through field 'deptDAO'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'deptDAO' defined in file [D:\Java Code\SpringCloud\provider\target\classes\com\vae\springcloud\dao\DeptDAO.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\Java Code\SpringCloud\provider\target\classes\mybatis\mapper\DeptMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [D:\Java Code\SpringCloud\provider\target\classes\mybatis\mapper\DeptMapper.xml]'. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for com.vae.springcloud.dao.DeptDAO.findAll. please check mybatis/mapper/DeptMapper.xml and file [D:\Java Code\SpringCloud\provider\target\classes\mybatis\mapper\DeptMapper.xml]
很奇怪的错误,我看错误说没有bean,我在网上搜啊搜,网上的文章要么是抄袭的,要么是复制粘贴的,要么解释的答案简单的很,根本没有上升到我这个层次。我纠结了好几天,最终发现,错误居然是!!!居然是Mybatis的配置文件!!
我自己写的mybatis文章里面,说道,mybatis加载mapper.xml需要这样
<!-- 加载映射文件-->
<mappers>
<mapper resource="config/Message.xml"/>
</mappers>
这样是可行,但是,这就是造成我错误的原因。这种方式,我当时使用的是SqlSession来主动加载Mybatis文件的,现在我想自动的去映射,就不能这么写了,需要在yml配置文件里面写
mybatis:
config-location: classpath:mybatis/mybatis.cfg.xml # mybatis配置文件所在路径
type-aliases-package: com.atguigu.springcloud.entities # 所有Entity别名类所在包
mapper-locations: classpath:mybatis/mapper/**/*.xml # mapper映射文件
总之,这次的错误,完全是因为我不熟悉Mybatis造成的,为此困惑了好多天。
顺便一提,我正在学习的这个项目是SpringCloud,学会之后,我会专门去详细的讲SpringCloud。到时再提一提这个因为我的无知而造成的报错。
Error creating bean with name的更多相关文章
- 【解决方案】 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userHandler': Injection of resource dependencies failed;
一个错误会浪费好多青春绳命 鉴于此,为了不让大家也走弯路,分享解决方案. [错误代码提示] StandardWrapper.Throwableorg.springframework.beans.fac ...
- [bigdata] 启动CM出现 “JDBC Driver class not found: com.mysql.jdbc.Driver” 以及“Error creating bean with name 'serverLogFetcherImpl'”问题的解决方法
问题:“JDBC Driver class not found: com.mysql.jdbc.Driver” 通过以下命令启动cm [root@hadoop1 ~]# /etc/init.d/cl ...
- Spring 异常:Error creating bean with name
异常信息:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxx' 我今 ...
- Java AOP nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice || Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0' 两个异常解决办法
贴出applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans ...
- Error creating bean with name 'menuController': Injection of autowired dependency……
出现了一大串错误 Error creating bean with name 'userController': Injection of autowired dependencies failed. ...
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; neste
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFacto ...
- eclipse 启动tomcat报Spring错误 Error creating bean with name 'serviceOrderBiz': Injection of autowired dependencies failed
启动tomcat报异常,提示Sring无法创建serviceOrderBiz(第一行红字),继续看是因为有一个自动注入的字段无法注入ModuleInterfaceBiz(第二行红字),检查servic ...
- Error creating bean with name 'bookDao'
“Error creating bean with name 'bookDao' defined in ServletContext resource [/WEB-INF/applicationCon ...
- Error creating bean with name 'memcachedClient'...java.lang.OutOfMemoryError
1,Tomcat启动报错例如以下: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating ...
- Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer'
@Configuration public class HttpSessionConfig { @Bean public static ConfigureRedisAction configureRe ...
随机推荐
- linux内核调试技巧之一 dump_stack【转】
在内核中代码调用过程难以跟踪,上下文关系复杂,确实让人头痛 调用dump_stack()就会打印当前cpu的堆栈的调用函数了. 如此,一目了然的就能看到当前上下文环境,调用关系了 假设: 遇到uvc_ ...
- 让 Windows7 - 64bit 支持 VC++ 6.0 的解决方法(无法启动此程序,因为计算机中丢失 MSVCRTD.dll。尝试重新安装该程序以解决此问题)
源地址:https://www.cnblogs.com/poissonnotes/p/4372136.html 无法启动此程序,因为计算机中丢失 MSVCRTD.dll.尝试重新安装该程序以解决此问题 ...
- ubuntu创建idea桌面快捷方式
This method can be used to create a launcher for any application, not just IntelliJ IDEA. For any la ...
- HTML5 canvas clearRect() 方法
浏览器支持 Internet Explorer 9.Firefox.Opera.Chrome 以及 Safari 支持 clearRect() 方法. 注释:Internet Explorer 8 或 ...
- js前端导出Excel表格后数字自动变成科学计数法问题
一般的文件导出都是后端进行导出,最近一个项目遇到导出接口挂掉了,前端实现导出的情况. 背景是vue框架,iView组件.可以直接使用exportCsv方法进行导出. 导出时进行一下行和列的切割就可以了 ...
- 从开始到头皮炸裂的python第5天
头皮炸裂的一天从学到一个新的数据类型开始,这个数据类型的新成员叫做字典,基本的格式为data={键:值,键:值},info.keys()表示所有的键,info.values()表示所有的值,info. ...
- adb常用命令(golang版)及输入中文
package main import ( "crypto/md5" "fmt" "image/png" "io/ioutil&q ...
- Linux内核入门到放弃-时间管理-《深入Linux内核架构》笔记
低分辨率定时器的实现 定时器激活与进程统计 IA-32将timer_interrupt注册为中断处理程序,而AMD64使用的是timer_event_interrupt.这两个函数都通过调用所谓的全局 ...
- ELK原理与简介
为什么用到ELK: 一般我们需要进行日志分析场景:直接在日志文件中 grep.awk 就可以获得自己想要的信息.但在规模较大的场景中,此方法效率低下,面临问题包括日志量太大如何归档.文本搜索太慢怎么办 ...
- Linux下Power Management开发总结
本文作为一个提纲挈领的介绍性文档,后面会以此展开,逐渐丰富. 1. 前言 在 <开发流程>中介绍了PM开发的一般流程,重点是好的模型.简单有效的接口参数.可量化的测试环境以及可独性强的输出 ...