ERROR org.springframework.security.core.SpringSecurityCoreVersion - *** Spring Major version' 3'预期,但您运行的版本:2.5.6

时间:2014-06-04 08:09:21

标签: java spring model-view-controller

在我的春季MVC项目中,我收到以下错误。 我刚刚导入了项目并解决了依赖关系并尝试运行,而不是maven项目。同样的项目在我的办公室PC上工作正常。任何帮助将不胜感激。以下是错误消息的片段:

< ---- ---剪断>

1 [localhost-startStop-1] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
197 [localhost-startStop-1] INFO org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Wed Jun 04 13:33:30 IST 2014]; root of context hierarchy
316 [localhost-startStop-1] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-security.xml]
1019 [localhost-startStop-1] INFO org.springframework.security.core.SpringSecurityCoreVersion - You are running with Spring Security Core 3.1.0.RELEASE
1019 [localhost-startStop-1] ERROR org.springframework.security.core.SpringSecurityCoreVersion - *** Spring Major version '3' expected, but you are running with version: 2.5.6. Please check your classpath for unwanted jar files.
1019 [localhost-startStop-1] WARN org.springframework.security.core.SpringSecurityCoreVersion - **** You are advised to use Spring 3.0.6.RELEASE or later with this version. You are running: 2.5.6
1019 [localhost-startStop-1] INFO org.springframework.security.config.SecurityNamespaceHandler - Spring Security 'config' module version is 3.1.0.RELEASE
1171 [localhost-startStop-1] INFO org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'permitAll' for /login
1171 [localhost-startStop-1] INFO org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'hasRole('ROLE_ADMIN')' for /web/manage/requests
1171 [localhost-startStop-1] INFO org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser - Creating access control expression attribute 'hasRole('ROLE_USER')' for /web/**
1212 [localhost-startStop-1] INFO org.springframework.security.config.http.HttpSecurityBeanDefinitionParser - Checking sorted filter chain: [Root bean: class [org.springframework.security.web.access.channel.ChannelProcessingFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 100, Root bean: class [org.springframework.security.web.context.SecurityContextPersistenceFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 200, Root bean: class [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 400, Root bean: class [org.springframework.security.web.authentication.logout.LogoutFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 700, <org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0>, order = 1100, Root bean: class [org.springframework.security.web.authentication.www.BasicAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1500, Root bean: class [org.springframework.security.web.savedrequest.RequestCacheAwareFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1600, Root bean: class [org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1700, Root bean: class [org.springframework.security.web.authentication.AnonymousAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2000, Root bean: class [org.springframework.security.web.session.SessionManagementFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2100, Root bean: class [org.springframework.security.web.access.ExceptionTranslationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2200, <org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0>, order = 2300]
1281 [localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
java.lang.NoSuchMethodError: org.springframework.core.OrderComparator.sort(Ljava/util/List;)V
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:92)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:381)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Jun 04, 2014 1:33:31 PM org.apache.catalina.core.StandardContext listenerStart

3 个答案:

答案 0 :(得分:1)

当Spring-core版本与Spring-security-core版本不兼容时,可以看到这种情况。您可能需要检查项目的依赖关系树,以检查正在使用的Spring库的版本。确保你有兼容的spring-core版本,它应该可以正常工作。

答案 1 :(得分:0)

看起来像spring-core版本是错误的,因为spring-core版本v2.5.6中没有签名OrderComparator.sort(List)的方法

您必须在项目中使用兼容版本的spring-core。即spring-core-3.2.6.RELEASE.jar

答案 2 :(得分:0)

您可以从错误日志中看到:

java.lang.NoSuchMethodError: org.springframework.core.OrderComparator.sort(Ljava/util/List;)V

这实际上意味着您正在使用的org.springframework.core版本中的“OrderComparator”类中名为“sort”的方法不存在。在查看spring-core的API之后,我发现OrderComparator的sort方法是在版本3.0.0.RELEASE中为一个对象数组添加的(参见Spring 3.0.0.RELEASE API documentation),即

static void sort(Object [] array)

Spring-Core 3.1.0.RELEASE中引入了另一种List类型的方法(参见Spring 3.1.0.RELEASE API documentation),即

static void sort(List <?> list)

tldr;确保您至少使用spring-core版本3.1.0.RELEASE。