Spring 4.0.X-beans中springDefinitionBuilder中setSource的替代方法

时间:2014-07-19 05:56:29

标签: java spring security spring-mvc spring-security

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:security="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
                        http://www.springframework.org/schema/security 
            http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
    <security:http access-denied-page="/jsp/403.jsp">
        <security:form-login login-page="/login/reDirect.jsp"
            authentication-failure-url="/login/reDirect.jsp?error=true"
            default-target-url="/jsp/main.jsp" />
        <security:anonymous />
        <security:http-basic />
        <security:logout logout-url="/logout.action"
            logout-success-url="/login/login.jsp" />
    </security:http>

我遇到了这个错误,同时将spring 2.5.6 升级为 4.0.4

    Exception sending context initialized event to listener instance of class                   
    org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration     problem: Failed to import bean definitions from URL location [classpath:com/essar/mes/hpl/config/spring-security.xml]
    Offending resource: class path resource [com/essar/mes/hpl/config/spring-config.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [com/essar/mes/hpl/config/spring-security.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.support.BeanDefinitionBuilder.setSource(Ljava/lang/Object;)Lorg/springframework/beans/factory/support/BeanDefinitionBuilder;

这表明Spring 4.0中的springDefinationBuilder中的setSource中没有方法.X-beans

有没有办法解决这个问题?

1 个答案:

答案 0 :(得分:-1)

至少需要Spring Spring 3.0.0 for Spring 4,或者你需要一个较旧的Spring 3.2.x版本用于Spring Security 2.0.x.从Spring 2.5开始,该方法已被标记为已弃用,并在Spring 4中完全删除。