spring安全配置错误-xsi:schemalocation

jjjwad0x  于 2021-07-12  发布在  Java
关注(0)|答案(0)|浏览(362)

我已经将Spring Security 添加到我的web应用程序中,并设法使用xsd位置uri对其进行配置和工作http://www.springframework.org/schema/security/spring-security-4.2.xsd . 这是我的工作配置,名为security-context.xml:

<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/security http://www.springframework.org/schema/security/spring-security-4.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    <security:authentication-manager>
        <security:authentication-provider>
            <security:user-service>
                <security:user name="primaryadmin" authorities="admin"
                    password="dummypass" />
                <security:user name="secondaryadmin" authorities="admin"
                    password="dummypass" />
            </security:user-service>
        </security:authentication-provider>
    </security:authentication-manager>
    <security:http use-expressions="true">
        <security:intercept-url pattern="/**" access="isAuthenticated()" />
        <security:form-login />
    </security:http>
</beans>

我面临的问题是,这个xsd文件的最高版本在这个位置是4.2,所以当我想将maven依赖项(spring security core、spring security web、spring security config)与更高版本5.2.1.release一起使用时,它失败了,告诉我应该将模式声明更新为5.2模式。
我试图通过将xsd位置uri替换为http://www.springframework.org/schema/beans/spring-beans.xsd 但我在部署过程中遇到了一个错误:

Caused by: org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 35; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'security:authentication-manager'.

我还试图通过引用maven下载的包含xsd文件的jar来解决这个问题,但这也不起作用:

<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/security classpath:org/springframework/security/config/spring-security-4.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
    <security:authentication-manager>

<security:authentication-manager> 第i行出现以下编译错误:

Element type "beans" must be followed by either attribute specifications, ">" or "/>".

我想用更高版本替换这些依赖项的原因是使它们使用与我的其他spring组件相同的版本。删除类路径:在相对路径的开头没有帮助。
我已经钻研了一堆相关的问题和答案,但没有一个能解决这个问题,你能给我建议吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题