Spring 菜鸟教程 异常 集锦
异常1.空指针异常
异常信息摘要:
java.lang.NullPointerExceptionat com.jege.framework.service.UserServiceTest.get(UserServiceTest.java:36)
异常信息说明:server接口没有注入
解决思路:可能的原因:
1.xml版本,没有写set方法,spring配置文件配置注入写的有问题
2.注解版本,没有写@Autowired或者@Resource
3.测试类上面没有标注
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
异常2.bean的名字name或者id已经存在
异常信息摘要:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Bean name 'helleService' is already used in this <beans> element
异常信息说明:helleService bean对象已经存在
解决思路:把重复的名字改一下:
异常3.web项目找不到默认配置文件
异常信息摘要:
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML
document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [WEB-INF/applicationContext.xml] cannot be opened because it does not exist
异常信息说明:web项目默认会在WEB-INF下找applicationContext.xml配置文件
解决思路:在web.xml配置一个上下文属性:
<context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value>
</context-param>
异常4.命名空间配置错误
异常信息摘要:
nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict,
but no declaration can be found for element 'aop:confog'.
异常信息说明:没有找到aop:confog的配置
解决思路:配置好schema的aop命名空间
xmlns:aop="http://www.springframework.org/schema/aop"
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
异常5.bean不是唯一的异常
异常信息摘要:
org.springframework.beans.factory.NoUniqueBeanDefinitionException:
No qualifying bean of type [com.jege.ssh.dao.IUserDao] is defined:
expected single matching bean but found 2: UserDao1,UserDao2at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:313)
异常信息说明:注入的接口有2个实现
解决思路:去掉一个实现类,一个接口最好只有一个实现
异常6.bean没有定义,不存在
异常信息摘要:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userDao' is defined
异常信息说明:userDao没有定义
解决思路:在applicationContext.xml中找不到id为userDao的bean,配置一下或者注解没有标注@Repository
异常7.server接口没有注入
异常信息摘要:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.jege.framework.service.UserServiceTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.jege.framework.service.IUserService com.jege.framework.service.UserServiceTest.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.jege.framework.service.IUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.jege.framework.service.IUserService com.jege.framework.service.UserServiceTest.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.jege.framework.service.IUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.jege.framework.service.IUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
异常信息说明:server接口没有注入
解决思路:可能的原因:
1.xml版本,没有写set方法,spring配置文件配置注入有问题
2.注解版本,<context:component-scan base-package="com.jege.framework包写错" />
异常8.aspectjweaver-1.8.0.jar spring4要使用高版本
如果觉得我的文章或者代码对您有帮助,可以请我喝杯咖啡。
您的支持将鼓励我继续创作!谢谢!
Spring 菜鸟教程 异常 集锦相关推荐
- Spring Boot 菜鸟教程 异常 集锦
异常1.集成SPRing Data JPA 异常信息摘要: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataS ...
- Spring Boot 菜鸟教程 12 EasyPoi导出Excel下载
GitHub src="//ghbtns.com/github-btn.html?user=je-ge&repo=spring-boot&type=watch&cou ...
- 菜鸟教程python3-Python数据分析,学习路径拆解及资源推荐
原标题:Python数据分析,学习路径拆解及资源推荐 关于Python数据分析,其实网上能够找到的学习资源很多,主要分为两类: 一类是提供各种资源的推荐,比如书单.教程.以及学习的先后顺序: 另一类是 ...
- python菜鸟教程字典-Python3 字典
Python3 字典 字典是另一种可变容器模型,且可存储任意类型对象. 字典的每个键值 key=>value 对用冒号 : 分割,每个对之间用逗号(,)分割,整个字典包括在花括号 {} 中 ,格 ...
- python菜鸟教程字典-python教程菜鸟教程学习路线
python教程菜鸟教程学习路线,需要学Python 环境搭建.Python 中文编码.Python 基础语法.Python 变量类型.Python 运算符.Python 条件语句.Python 循环 ...
- 菜鸟教程中Java语法(Java教程+Java面向对象)
Java基本数据类型 Java变量类型 Java运算符 Java循环语句 Java条件语句 Java switch case Java Number & Math类 Java Characte ...
- 菜鸟教程 之 JavaScript 教程
From:菜鸟教程 JavaScript:https://www.runoob.com/ W3School JavaScript 教程:http://www.w3school.com.cn/js/in ...
- python3字典菜鸟教程_Python3 字典(map)
ayout: post title: Python3 字典(map) author: "luowentaoaa" catalog: true tags: mathjax: true ...
- 菜鸟教程python3 mysql_python基础教程使用Python操作MySQL的小技巧
1.获取插入数据的主键id import pymysql database = pymysql.connect( host="127.0.0.1", port=3306, user ...
- 《菜鸟教程》之基础教程
目录 一.基础教程 2.1 基本知识点 2.2 重要知识点 二.高级教程 2.1 网络编程: 2.2 多线程: 2.3 python3 MySQL编程: 2.4 python调用C语言 一.基础教程 ...
最新文章
- 综合布线工作组2008年上半年技术课题工作安排会议通知
- Go 面向对象三大特性
- C++ volatile关键字说明
- 单片机备用电池供电电路_第五节(重排) 电子入门 复位电路
- Android应用开发基础 余永佳,Android应用开发基础(基于Android4.2、任务驱动式)教学课件作者余永佳赵佩华习题课件.doc...
- puppet中anchor的作用
- linux系统expdp按表空间导出,expdp导出是全库吗
- shark恒破解笔记3-EAX决定胜负
- 通过USB设置手机连接电脑上网
- mac brew的安装方法
- 磁盘性能指标监控实战
- XCTF MISC 我们的秘密是绿色的
- 1.华为分布式存储fusionstorage介绍
- 点击遮罩层的背景关闭遮罩层
- ubuntu从一个单纯的系统到装上自己需要的一些软件的过程
- .ignore插件自动忽略
- 用硬实力,好作品,砸开阿里的前端开发金饭碗
- skype 无法更新安装
- git tag怎么使用_这才是真正的 Git:Git 内部原理揭秘!
- Field userClient in com.xxx.UserController required a bean of type“com.xxx“that could not be found.
热门文章
- 数值计算方法的简单介绍
- 快应用如何避免JSON.parse()解析出错
- GPU — NVIDIA GPU 架构发展史
- 自己挖坑自己跳 之JsonMappingException: (was java.lang.NullPointerException) (through reference chain:)...
- 知名国产论坛,凉了!!!!
- 黑苹果系统引导工具正确安装步骤
- VS2013 ConsoleApplication1.exe”(Win32):无法查找或打开 PDB 文件。
- Veritas Backup Exec 22 (Windows)
- STM32 Boot模式设置方法
- 这才是晕了哟,dos之家上全是graybird???????????