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 ...
随机推荐
- js 学习之路7:switch/case语句的使用
语法格式: switch(n) { case 1: 执行代码块 1 break; case 2: 执行代码块 2 break; default: n 与 case 1 和 case 2 不同时执行的代 ...
- Linux 系统进程相关命令
1.pstree :可以使用pstree命令来查看系统中进程的分布结构. 2.ps: 常用于查看系统进程的命令是ps(process status)命令,可通过它来查看系统进程的最基本信息. ●-A ...
- 指定IP地址进行远程访问服务器设置方法(windows系统)
我们有很多服务器经常受到外界网络的干扰,入侵者们通过扫描3389端口爆破密码非法进入我们的服务器,这时,我们可以配置服务器IP 安全策略来限制一些IP访问,大大提高了服务器的安全. 实验环境: ...
- A Deep Learning-Based System for Vulnerability Detection
本篇文献作者提出了一种基于深度学习来检测软件漏洞的方案. 摘要:作者开始基于深度学习的漏洞检测研究,是为了减轻专家手工定义特性的繁琐任务,需要制定一些指导性原则来适用于深度学习去进行漏洞探 ...
- Docker:测试环境的准备-centos7上安装docker
Dockers官方部署文档:https://docs.docker.com/install/linux/docker-ce/centos/ 1.建议先关闭 selinux (selinux是 linu ...
- requests的基本用法
r = requests.get('https://api.github.com/events', params = {'key1': 'value1', 'key2': 'value2'}) r = ...
- Redis学习笔记(5)——Redis数据持久化
出处http://www.cnblogs.com/xiaoxi/p/7065328.html 一.概述 Redis的强大性能很大程度上都是因为所有数据都是存储在内存中的,然而当Redis重启后,所有存 ...
- Python爬虫【实战篇】获取网易云歌词
先看代码 import requests import json headers = { "User-Agent": "Mozilla/5.0 (iPhone; CPU ...
- Python爬虫【实战篇】百度翻译
先看代码 import requests headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS ...
- Linux删除隐藏文件
方法2.ls -a 查询隐藏文件 将后缀名为.swp的文件删除 rm -f .nginx.conf.swp 再次编辑文件不在出现提示警告!