由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Spring菜鸟求救
相关主题
multiple PropertyPlaceHolderConfigurer in spring applicationContext.xml?有熟悉Java Reflection的吗
maven,struts求助一道java题
a stupid questionQuestion: EJB Web Services Integration
Spring JBOSSdeserializer probelm.Ignore upper. Thx
问一个spring dynamic module/OSGi的问题让大家了解工业界Java/J2EE面试题的难度
So weird.Anyone know SAML 2.0 and OpenSAML ?
问题征解spring web service issue
问个基本问题两种方式有什么不同
相关话题的讨论汇总
话题: texteditor话题: class话题: public话题: bean
进入Java版参与讨论
1 (共1页)
x******m
发帖数: 736
1
跟着网上的tutorial学习,一模一样的code,总是出错。
第一个class
package com.springinaction.springidol;
public class SpellChecker {
public SpellChecker(){
System.out.println("Inside SpellChecker constructor." );
}
public void checkSpelling() {
System.out.println("Inside checkSpelling." );
}

}
第二个class
package com.springinaction.springidol;
public class TextEditor {
private SpellChecker spellChecker;
public TextEditor(SpellChecker spellChecker) {
System.out.println("Inside TextEditor constructor." );
this.spellChecker = spellChecker;
}
public void spellCheck() {
spellChecker.checkSpelling();
}
}
然后main
package com.springinaction.springidol;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainApp {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("com/
springinaction/springidol/spring-idol.xml");
TextEditor te = (TextEditor) context.getBean("textEditor");
te.spellCheck();
}
}
这是xml

http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">








run MainApp的时候
为什么总是报错:
Exception in thread "main" java.lang.IncompatibleClassChangeError: class org
.springframework.core.LocalVariableTableParameterNameDiscoverer$
ParameterNameDiscoveringVisitor has interface org.springframework.asm.
ClassVisitor as super class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.springframework.core.LocalVariableTableParameterNameDiscoverer.
inspectClass(LocalVariableTableParameterNameDiscoverer.java:112)
at org.springframework.core.LocalVariableTableParameterNameDiscoverer.
getParameterNames(LocalVariableTableParameterNameDiscoverer.java:85)
at org.springframework.beans.factory.support.ConstructorResolver.
autowireConstructor(ConstructorResolver.java:190)
at org.springframework.beans.factory.support.
AbstractAutowireCapableBeanFactory.autowireConstructor(
AbstractAutowireCapableBeanFactory.java:1075)
at org.springframework.beans.factory.support.
AbstractAutowireCapableBeanFactory.createBeanInstance(
AbstractAutowireCapableBeanFactory.java:979)
at org.springframework.beans.factory.support.
AbstractAutowireCapableBeanFactory.doCreateBean(
AbstractAutowireCapableBeanFactory.java:487)
at org.springframework.beans.factory.support.
AbstractAutowireCapableBeanFactory.createBean(
AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.
getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.
DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:
223)
at org.springframework.beans.factory.support.AbstractBeanFactory.
doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:628)
at org.springframework.context.support.AbstractApplicationContext.
finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
at org.springframework.context.support.AbstractApplicationContext.
refresh(AbstractApplicationContext.java:423)
at org.springframework.context.support.ClassPathXmlApplicationContext.<
init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<
init>(ClassPathXmlApplicationContext.java:83)
at com.springinaction.springidol.MainApp.main(MainApp.java:7)
s****y
发帖数: 503
2
应该是你的Spring包没有导对 可能版本不对
l*******o
发帖数: 250
3
用 4.0.4,检查pom,去掉asm reference
g*****g
发帖数: 34805
4
不同spring jar的版本不一致。
c*********e
发帖数: 16335
5
spring最花時間的就是调试,用eclipse, maven, spring调试的时候,可能是pom里的
几个spring-core什么的版本不一致,或者在4.0以後还加了asm. 最好找个调好的,直
接把xml里面的code拷贝过来。

【在 x******m 的大作中提到】
: 跟着网上的tutorial学习,一模一样的code,总是出错。
: 第一个class
: package com.springinaction.springidol;
: public class SpellChecker {
: public SpellChecker(){
: System.out.println("Inside SpellChecker constructor." );
: }
: public void checkSpelling() {
: System.out.println("Inside checkSpelling." );
: }

x******m
发帖数: 736
6
搞定了,把asm去掉就好了,spring的这些dependency怎么这么乱,相互兼容性好差。
m*****u
发帖数: 1342
7
Probably has something to do with the J2EE (JEE), the pom.xml and Maven
helps the dependency problem, but did not eliminate it :-)

【在 x******m 的大作中提到】
: 搞定了,把asm去掉就好了,spring的这些dependency怎么这么乱,相互兼容性好差。
T*********g
发帖数: 496
8
內什么,你应该用下maven。show effective让你的依赖一目了然

【在 x******m 的大作中提到】
: 搞定了,把asm去掉就好了,spring的这些dependency怎么这么乱,相互兼容性好差。
1 (共1页)
进入Java版参与讨论
相关主题
两种方式有什么不同问一个spring dynamic module/OSGi的问题
Spring的新手问题So weird.
求OpenShift上Spring-quickstart的mysql配置方法问题征解
关于 Java bean问个基本问题
multiple PropertyPlaceHolderConfigurer in spring applicationContext.xml?有熟悉Java Reflection的吗
maven,struts求助一道java题
a stupid questionQuestion: EJB Web Services Integration
Spring JBOSSdeserializer probelm.Ignore upper. Thx
相关话题的讨论汇总
话题: texteditor话题: class话题: public话题: bean