【发布时间】:2013-05-31 04:17:11
【问题描述】:
当我尝试运行 java 控制台应用程序时,我在 Red Hat 5 上看到以下错误,但在 Ubuntu 上没有。
另一个 StackOverflow post 提到不要混合使用 spring 2 和 3 的版本。
但我运行find [where I run app - includes classpath] | grep spring | grep 3 并看到 0 个结果。因此,我相信这不是spring 版本问题。
> Exception in thread "main"
> org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
> Configuration problem: Failed to import bean definitions from URL
> location
> [classpath:/org/eurekastreams/server/conf/applicationContext-model.xml]
> Offending resource: class path resource [conf/applicationContext.xml];
> nested exception is
> org.springframework.beans.factory.BeanDefinitionStoreException:
> Unexpected exception parsing XML document from class path resource
> [org/eurekastreams/server/conf/applicationContext-model.xml]; nested
> exception is java.lang.NoSuchMethodError:org.springframework.aop.config.
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary
(Lorg/springframework/beans/factory/xml/ParserContext;
Lorg/w3c/dom/Element;)V
编辑
添加堆栈跟踪:
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans/factory/xml/ParserContext;Lorg/w3c/dom/Element;)V
运行mvn dependency:tree后,看到spring-aop.jar的几个版本:
$grep "spring-aop" mvn_dependency_tree.txt
[INFO] | +- org.springframework:spring-aop:jar:2.0.8:compile
[INFO] | | | +- org.springframework:spring-aop:jar:2.0.8:provided
[INFO] | | +- org.springframework:spring-aop:jar:2.0.8:compile
[INFO] | | +- org.springframework:spring-aop:jar:2.5.4:compile
这些不同版本的spring-aop 能否解释我添加的堆栈跟踪中的AOP 错误?
【问题讨论】:
-
我怀疑您的问题仍然是类路径上的多个 Spring 版本,可能不是版本 2 和 3。
-
同意,看来你很可能有版本冲突。您没有提供足够的信息来提供除此之外的任何输入。
-
嗯。如果我从同一目录运行应用程序,并在
Ubuntu和RHEL上运行$CLASSPATH,那么这个错误怎么会发生在一个,而不是另一个? -
NSME 仅在您针对具有您尝试调用的方法的库版本进行编译时发生,但随后使用该库的不同版本运行但没有针对您编译的方法。您的类路径中是否有可能有多个版本的 spring?如果有多个具有相同的类名,Java 会在您的类路径中任意选择 jar/类的版本。
-
multiple versions of spring表示同一jar的不同版本?示例:我的$CLASSPATH上有spring-core-2.5.5.jar,但也有spring-support-2.0.8.jar。可以吗?
标签: java