1
我的Spring bean配置文件存在问题。我正在使用Spring Tool Suite 3.4和Spring 3.1.1 jar(MVC,jdbc,security)。这仅仅是在IDE的警告,但是当应用程序被加载到应用服务器它显示了以下错误Spring配置文件命名空间的解决
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]
在你的建议之后 - 来自spring-security-web jar(或它的一个依赖关系)的类不可用 –
我以前没见过这个问题。快速谷歌给了我这个.. http://forum.spring.io/forum/spring-projects/security/102538-configuration-problem-spring-security-web-classes-are-not-available-you-need – dectarin
我在这里创建了一个示例项目,使用上面粘贴的相同安全性上下文,它对我有用,所以如果您可以为我提供pom.xml文件的内容 – dectarin