1

我的 Spring bean 配置文件中的问题。我正在使用 Spring Tool Suite 3.4 和 Spring 3.1.1 jar(MVC、jdbc、安全)。这只是 IDE 中的一个警告,但是当应用程序加载到 APP Server 时,它会显示以下错误

Spring Configuration File - login-security.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans          http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">

<beans:import resource='login-service.xml'/> 
     <security:http> 
     <security:intercept-url pattern='/home*' access='ROLE_USER,ROLE_ADMIN' /> 
     <security:intercept-url pattern='/admin*' access='ROLE_ADMIN' /> 
     <security:form-login login-page='/login.jsp' default-target-url='/home' authentication-failure-url='/login.jsp?error=true'/> 
     <security:logout logout-success-url='/login.jsp' /> 
     <security:anonymous username='guest' granted-authority='ROLE_GUEST'/> 
     <security:remember-me/> 
</security:http>

 <security:authentication-manager> 
     <security:authentication-provider> 

       <security:jdbc-user-service data-source-ref='myDataSource' 
           users-by-username-query="select username, password, 'true' as enabled from USER_DETAILS where username=?"
           authorities-by-username-query="select USER_DETAILS.username , USER_AUTH.AUTHORITY as authorities from USER_DETAILS,USER_AUTH 
           where USER_DETAILS.username = ? AND USER_DETAILS.username=USER_AUTH.USERNAME"></security:jdbc-user-service>

     </security:authentication-provider>
   </security:authentication-manager>  

WARNING. ERROR IN CONSOLE - org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]
Offending resource: ServletContext resource [/WEB-INF/spring/appServlet/login-security.xml]

在此处输入图像描述

4

1 回答 1

0

我认为您可能缺少 pom.xml 中的 spring security config 依赖项。

尝试将此添加到您的 pom.xml

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>

希望这可以帮助。

于 2014-03-30T13:50:36.253 回答