java.lang.IllegalArgumentException异常处理的一种方法
我遇到的问题
用spring注解来加载bean,都是一个简单的了,但是还是报了这样一个错java.lang.IllegalArgumentException
网上查了一下,说是jdk版本要1.7的,然后我就改了,就好了。
Person.java
package com.xiaostudy.service; import org.springframework.stereotype.Component; @Component("person")
public class Person { }
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"> <context:component-scan base-package="com.xiaostudy.service"></context:component-scan>
</beans>
测试类Test.java
package com.xiaostudy.service; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; import com.xiaostudy.service.Person; public class Test { public static void main(String[] args) {
ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
Person person = ac.getBean("person", Person.class);
System.out.println(person);
} }
错误信息
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [E:\IT\spring3\demo9\bin\com\xiaostudy\service\Person.class]; nested exception is java.lang.IllegalArgumentException
解决问题
1、把eclipse的jdk调整为1.7
2、新建项目的jdk选择1.7
java.lang.IllegalArgumentException异常处理的一种方法的更多相关文章
- bug_ _ java.lang.IllegalArgumentException: pointerIndex out of range 问题的两种解决办法
========== 4 如何解决java.lang.IllegalArgumentException: pointerIndex out of range? 今天遇到一个bug:java.l ...
- JMeter学习-027-JMeter参数文件(脚本分发)路径问题:jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumentException: File distributed.csv must exist and be readable解决方法
前些天,在进行分布式参数化测试的时候,出现了如题所示的错误报错信息.此文,针对此做一个简略的重现及分析说明. JMX脚本线程组参数配置如下所示: 参数文件路径配置如下所示: 执行JMX脚本后,服务器对 ...
- Exception in thread "main" java.lang.IllegalArgumentException:解决方法
使用fileSystem的delete方法无法删除文件或目录 Exception in thread "main" java.lang.IllegalArgumentExcepti ...
- java.lang.IllegalArgumentException: An invalid domain [.test.com] was specified for this cookie解决方法
当项目中使用单点登录功能时,通常会使用cookie进行信息的保存,这样就可以在多个子域名上存取用户信息. 比如有三个domain分别为test.com,cml.test.com,b.test.com这 ...
- [zhuan]Android 异常处理:java.lang.IllegalArgumentException(...contains a path separator)
http://blog.csdn.net/alex_zhuang/article/details/7340901 对以下错误: Java.lang.RuntimeException: java.lan ...
- java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)异常解决方法
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start com ...
- Hibernate查询出现java.lang.IllegalArgumentException异常解决方法
Hibernate查询出现java.lang.IllegalArgumentException. 异常信息如下:java.lang.IllegalArgumentException at ...
- java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@450b2f48 异常处理
晕死的错误,改了半天也没想到是这样的原因,基础正要呀... 先看一下警告信息: 07-07 08:32:19.540: WARN/WindowManager(74): Failed looking u ...
- java.lang.IllegalArgumentException的解决方法
java.lang.IllegalArgumentException这个错误基本上就是jdk版本的问题 把jdk1.8换成jdk1.7就可以了 这里可以设置jdk最低版本 这里默认要选择jdk1.7 ...
随机推荐
- 用vector构造自动扩容的二维数组
#include <iostream> #include <string> #include <vector> using namespace std; int m ...
- JZOJ.3777【NOI2015模拟8.17】最短路(shortest)
Description 小Y最近学得了最短路算法,一直想找个机会好好练习一下.话虽这么说,OJ上最短路的题目都被他刷光了.正巧他的好朋友小A正在研究一类奇怪的图,他也想凑上去求下它的最短 ...
- iOS tabbar 属性
1.设置tabbar背景颜色 NSArray *controllers = [NSArray arrayWithObjects:nav_main,nav_channle,nav_me, nil]; _ ...
- java操作mongoDB数据库的简单实例
首先导入mongoDB的jar包 http://pan.baidu.com/s/1bnGMJRD //DataBase.java package com.mongodb.test; import ja ...
- dot 使用笔记
Graphviz (英文:Graph Visualization Software的缩写)是一个由AT&T实验室启动的开源工具包,用于绘制DOT语言脚本描述的图形 sudo apt-get i ...
- SSH 框架整合总结
1. 搭建Struts2 环境 创建 struts2 的配置文件: struts.xml; 在 web.xml 中配置 struts2 的核心过滤器; // struts.xml <?xml v ...
- 单独使用celery
单独使用celery 参考 http://docs.celeryproject.org/en/latest/getting-started/index.html https://www.jianshu ...
- pycharm中选择python interpreter
pycharm中选择python interpreter pycharm中有两处地方需要选择python解释器: 一处是调试配置(edit configurations)处,这里选择python解释器 ...
- 3.Write Scripts for the mongo Shell-官方文档摘录
总结 1 使用js进行获取数据的方法 2 js方式和原生mongo shell的交互方式的区别写法 3 需要将所有数据打印出来使用到的循环示例 cursor = db.collection.find( ...
- Django - ModelForm组件
一.ModelForm组件 这是一个神奇的组件,通过名字我们可以看出来,这个组件的功能就是把model和form组合起来,先来一个简单的例子来看一下这个东西怎么用:比如我们的数据库中有这样一张学生表, ...