복붙노트

[SPRING] 스프링 보안 없음 WebApplicationContext가 발견되었습니다.

SPRING

스프링 보안 없음 WebApplicationContext가 발견되었습니다.

나는 봄의 안전에 새로운 사람이다.

나는 web.xml을 가지고있다.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

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

<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

applicationContext-security.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"
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-3.0.xsd">
<http auto-config="true">
    <intercept-url pattern="/register.html" access="IS_AUTHENTICATED_ANONYMOUSLY" />
    <intercept-url pattern="/*" access="ROLE_USER, ROLE_ADMIN" />       
    <logout logout-url="/logout"/>
</http>

<beans:bean id="myUserDetailsService" class="labas.spring.service.UserDetailsImp"/>

<authentication-manager>
    <authentication-provider user-service-ref='myUserDetailsService'/>
</authentication-manager>

어떤 이유는 내가 그것을 실행할 때 나는 얻는다.

뭐가 잘못 되었 니?

해결법

  1. ==============================

    1.루트 WebApp 컨텍스트를 선언하지 않았습니다. contextConfigLocation을 추가했지만 사용하는 리스너는 추가하지 않았습니다.

    루트 WebApp 컨텍스트를 선언하지 않았습니다. contextConfigLocation을 추가했지만 사용하는 리스너는 추가하지 않았습니다.

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
  2. from https://stackoverflow.com/questions/5046403/spring-security-no-webapplicationcontext-found by cc-by-sa and MIT license