[java] Spring 3.0-XML 스키마 네임 스페이스를위한 Spring NamespaceHandler를 찾을 수 없음 [http://www.springframework.org/schema/security]

이것의 원인이 될 수있는 아이디어가 있습니까?

XML 스키마 네임 스페이스에 대한 Spring NamespaceHandler를 찾을 수 없음 [ http://www.springframework.org/schema/security]

org.springframework.web.context.ContextLoader initWebApplicationContext: Context initialization failed
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/applicationContext.xml]

이것은 내 applicationContext.xml입니다.

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
    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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-3.0.xsd">
...
</beans:beans>

내 pom.xml에는 다음이 있습니다.

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>3.0.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-openid</artifactId>
    <version>3.0.1.RELEASE</version>
</dependency>



답변

추가 Maven 종속성을 추가해야했습니다.

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


답변

응용 프로그램을 배포하는 동안 동일한 오류 메시지가 나타납니다. Spring에서 보안 구성 xml은 applicationContext.xml과는 다를 수 있으며 일반적으로 WEB-INF 폴더 내의 applicationContext-security.xml입니다. 적용 할 변경 사항은 web.xml에 대한 것입니다.

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/applicationContext.xml
        /WEB-INF/applicationContext-security.xml
    </param-value>
</context-param>

그리고 applicationContext.xml은 다음과 같습니다.

<?xml version="1.0" encoding="UTF-8"?>
<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-3.0.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <http auto-config='true'>
        <intercept-url pattern="/login.jsp" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
        <intercept-url pattern="/**" access="ROLE_USER" />
        <form-login login-page='login.jsp'/>
    </http>

</beans:beans>

이러한 변경을 수행 한 후에도 네임 스페이스 오류가 발생합니다. 이를 제거하려면 다음 jar 파일을 WEB-INF / lib 및 라이브러리에 추가하십시오.

  • spring-security-acl-3.1.0.M2.jar
  • spring-security-config-3.1.0.M2.jar
  • spring-security-core-3.1.0.M2.jar
  • spring-security-taglibs-3.1.0.M2.jar
  • spring-security-web-3.1.0.M2.jar

답변

나는 이것을 잠시 동안 고투 했고이 답변들 중 어느 것도 도움이되지 못했습니다. user64141 의 의견 덕분에 spring.handlers파일에 문제가 있음을 깨달았습니다 .

Maven 용 Shade 플러그인을 사용하여 뚱뚱한 항아리를 생성하고 모든 spring.handlers(및 spring.schemas) 파일이 각 Spring 종속성에 의해 덮어 쓰여졌습니다.

Maven 사이트는이 정확한 문제와 대신 파일을 함께 추가하여 해결하는 방법을 다룹니다.

http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#AppendingTransformer


답변

spring-security-config jar을 사용하여 문제가 해결되었습니다.


답변

해결책은 WEB-INF / lib에없는 “spring-security-config”입니다.

Maven을 사용하는 Eclipse의 프로젝트의 경우 모든 maven 종속성이 WEB-INF / lib에 복사되지는 않았습니다. 프로젝트-> 속성-> 배포 어셈블리를 보면 일부 항아리 만 복사되었습니다.

이 문제를 해결하기 위해 “추가”를 클릭 한 다음 “Java 빌드 경로 전체”를 클릭하고 마지막으로 “Maven 종속성”을 클릭했습니다.

나는 이것을 찾고있는 지난 한 시간 동안 SO와 웹을 검색 해 왔으므로 희망적으로 이것은 다른 누군가를 도울 것입니다.


답변

Maven 종속성의 좋은 목록은 다음 사이트 에 있습니다. Spring Site
필요한 주요 아티팩트는 다음과 같습니다.

  1. 스프링 보안 코어
  2. 봄 보안 웹
  3. 스프링 보안 구성

답변

@James Jithin-xsi : schemaLocation에 두 가지 버전의 Bean과 보안 스키마가있는 경우에도 이러한 예외가 발생할 수 있습니다. 붙여 넣은 스 니펫의 경우입니다.

xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/security
 http://www.springframework.org/schema/security/spring-security-3.1.xsd"

제 경우에는 둘 다 3.1로 변경하면 문제가 해결되었습니다.