在eclipse环境下,Spring扫描出现问题

翻斗吧 发布于 2015/02/07 17:44
阅读 8K+
收藏 0
package com.test;


import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


import com.bean.ExampleBean;


public class Test1 {


public static void main(String[] args) {


String conf="applicationContext.xml";
ApplicationContext ac=new ClassPathXmlApplicationContext(conf);
// ExampleBean bean=ac.getBean("exampleBean", ExampleBean.class);
// System.out.println(bean);
}


}

package com.bean;


import org.springframework.stereotype.Component;


@Component
public class ExampleBean {


public ExampleBean() {
System.out.println("1111");
}
}

<?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"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd     
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
 
<context:component-scan 
base-package="com"/>

</beans>


结果是Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\Workspace\eclipse.workspace\1\build\classes\com\bean\ExampleBean.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\Workspace\eclipse.workspace\1\build\classes\com\bean\ExampleBean.class]; nested exception is java.lang.IllegalArgumentException

Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\Workspace\eclipse.workspace\1\build\classes\com\bean\ExampleBean.class]; nested exception is java.lang.IllegalArgumentException

Caused by: java.lang.IllegalArgumentException


加载中
0
pantrick
pantrick

ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\Workspace\eclipse.workspace\1\build\classes\com\bean\ExampleBean.class]; nested exception is java.lang.IllegalArgumentException

spring 版本?

或者lib里存在不同版本的asm 包

pantrick
pantrick
回复 @翻斗吧 : 与环境没关系吧
翻斗吧
翻斗吧
但是在myeclipse下,上面代码就能使用啊
0
翻斗吧
翻斗吧
终于知道了,是Java版本问题
Nirow
Nirow
回复 @新手要努力 : 将项目的编译版本降到1.7试试。
新手要努力
我也是遇到这个问题,能告诉我是JAVA什么版本额问题么?谢谢!
返回顶部
顶部