加载spring applicationContext.xml文件时出现以下错误。知道是什么导致了这个吗?
Jan 14, 2015 10:33:27 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@e330e33: display name [org.springframework.context.support.FileSystemXmlApplicationContext@e330e33]; startup date [Wed Jan 14 10:33:27 CST 2015]; root of context hierarchy
Exception in thread "main" java.lang.NoSuchMethodError: org/springframework/core/CollectionFactory.createConcurrentMapIfPossible(I)Ljava/util/Map;
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.<init>(DefaultSingletonBeanRegistry.java:86)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.<init>(FactoryBeanRegistrySupport.java:41)
at org.springframework.beans.factory.support.AbstractBeanFactory.<init>(AbstractBeanFactory.java:146)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:144)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:155)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.<init>(DefaultListableBeanFactory.java:121)
at org.springframework.context.support.AbstractRefreshableApplicationContext.createBeanFactory(AbstractRefreshableApplicationContext.java:176)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:121)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
at com.visa.services.mtc.client.MTCWebSvcClientTest.main(MTCWebSvcClientTest.java:13)
答案 0 :(得分:0)
检查所有Spring Jars是否在同一版本上。
运行mvn dependency:tree
并检查是否所有版本号都在同一版本号上。
希望它有所帮助。
答案 1 :(得分:0)
在我的例子中,我在pom.xml
中放了两个不同版本的Spring库:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6.SEC03</version>
</dependency>
删除spring-core
已经有效。