【发布时间】:2013-01-14 11:06:10
【问题描述】:
您好,当我尝试从 Spring Security 2.0.4 迁移到 Spring Security 3.0.5.RELEASE 时遇到问题。我收到以下错误:
SEVERE: Exception sending context initialized event to listener instance of class pl.casses.fw.client.info.app.OfficeContextLoader
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/office-mgt-security.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.getLocalName(Lorg/w3c/dom/Node;)Ljava/lang/String;
我的 security.xml 文件在这里:
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="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-2.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<http auto-config='true'>
<intercept-url pattern="/**/*.ico" filters="none" />
<intercept-url pattern="/**/*.gif" filters="none" />
<intercept-url pattern="/**/*.jpg" filters="none" />
<intercept-url pattern="/**/*.css" filters="none" />
<intercept-url pattern="/**/*.js" filters="none" />
<intercept-url pattern="/**/*.png" filters="none" />
<intercept-url pattern="/logout.jsp*" filters="none" />
<intercept-url pattern="/index.jsp*" filters="none" />
<intercept-url pattern="/**" access="ROLE_USER,ROLE_ADMIN" />
<form-login login-page="/index.jsp"
authentication-failure-url="/index.jsp?login_error=1"
default-target-url="/main.jsp" always-use-default-target="true" />
<remember-me key="CassesOMRMKey" user-service-ref="userFactory"/>
</http>
<authentication-manager>
<authentication-provider user-service-ref="userFactory">
<password-encoder hash="md5" />
</authentication-provider>
</authentication-manager>
在 pom.xml 我有:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
我做错了什么?如何迁移到安全 3.0。提前感谢您的回答。
【问题讨论】:
-
尝试使用相同的spring版本,所以3.0.5...同时,既然你现在正在迁移,为什么不直接迁移到最新的spring版本?
-
阅读这篇常见问题的文章为好:packtpub.com/article/migration-to-spring-security-3
-
相同版本的使用对您有用吗?所以我将其发布为将来参考的答案
-
@mardavi:不幸的是,在 pom.xml 中简单地更改 spring 版本并不能解决问题。我遇到了许多不同的错误(因为我正在从事相当大的项目)。最新的春季版本是哪个?
-
Spring Framework 为 3.2.0.RELEASE,Spring Security 为 3.1.3.RELEASE。根据我的经验,这种不匹配的版本很常见,但几天后两者都会是 3.2.0.RELEASE。与您的情况一样,这并不总是一个问题,但一些同事告诉我,最好保持相同的版本