복붙노트

[SPRING] org.springframework.beans.factory.NoSuchBeanDefinitionException 오류 : 'springSecurityFilterChain'이라는 bean을 정의하지 않았습니다.

SPRING

org.springframework.beans.factory.NoSuchBeanDefinitionException 오류 : 'springSecurityFilterChain'이라는 bean을 정의하지 않았습니다.

스프링 보안을 사용하여 NTLM을 실행 중입니다. 다음과 같은 오류가 발생합니다.

이 오류를 어떻게 해결할 수 있습니까?

나는 web.xml에 다음을 정의했다.

<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>

업데이트 1

나는 그 오류를 해결했다.

나는 다음과 같은 것을 가지고있다.

<bean id="springSecurityFilterChain" class="org.acegisecurity.util.FilterChainProxy">
    <property name="filterInvocationDefinitionSource">
    <value>
    CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    PATTERN_TYPE_APACHE_ANT
    /**=httpSessionContextIntegrationFilter, exceptionTranslationFilter, ntlmFilter, filterSecurityInterceptor
    </value>
    </property>
    </bean>`

@Sean Patrick Floyd와 같이 일부 요소는 오래되고 죽은 채로 묻혀 있기 때문에 applicationContext.xml을 다음과 같이 변경했습니다. 그러나 지금 다른 오류가 수정해야합니다 :-)

감사

<?xml version="1.0" encoding="UTF-8"?>
<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/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd   http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.2.xsd">
  <!--<authentication-manager alias="_authenticationManager"></authentication-manager>-->
  <security:authentication-provider>
    <security:user-service>
      <security:user name="testuser" password="PASSWORD" authorities="ROLE_USER, ROLE_ADMIN"/>
      <security:user name="administrator" password="PASSWORD" authorities="ROLE_USER,ROLE_ADMIN"/>
    </security:user-service>
  </security:authentication-provider>
  <bean id="userDetailsAuthenticationProvider"
        class="com.icesoft.icefaces.security.UserDetailsAuthenticationProvider">
    <security:custom-authentication-provider/>
  </bean>
  <bean id="ntlmEntryPoint"
        class="org.springframework.security.ui.ntlm.NtlmProcessingFilterEntryPoint">
    <property name="authenticationFailureUrl" value="/accessDenied.jspx"/>
  </bean>
  <bean id="ntlmFilter" class="org.springframework.security.ui.ntlm.NtlmProcessingFilter">
    <security:custom-filter position="NTLM_FILTER"/>
    <property name="stripDomain" value="true"/>
    <property name="defaultDomain" value="domain"/>
    <property name="netbiosWINS" value="domain"/>
    <property name="authenticationManager" ref="_authenticationManager"/>
  </bean>
  <bean id="exceptionTranslationFilter"
        class="org.springframework.security.ui.ExceptionTranslationFilter">
    <property name="authenticationEntryPoint" ref="ntlmEntryPoint"/>
  </bean>
  <security:http access-decision-manager-ref="accessDecisionManager"
                 entry-point-ref="ntlmEntryPoint">
    <security:intercept-url pattern="/accessDenied.jspx" filters="none"/>
    <security:intercept-url pattern="/**" access="ROLE_USER"/>
  </security:http>
  <bean id="accessDecisionManager" class="org.springframework.security.vote.UnanimousBased">
    <property name="allowIfAllAbstainDecisions" value="false"/>
    <property name="decisionVoters">
      <list>
        <bean id="roleVoter" class="org.springframework.security.vote.RoleVoter"/>
      </list>
    </property>
  </bean>
</beans>

해결법

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

    1.DelegatingFilterProxy 문서에서 :

    DelegatingFilterProxy 문서에서 :

    응용 프로그램 컨텍스트에서 javax.servlet.Filter를 구현하는 springSecurityFilterChain이라는 bean을 정의해야합니다.

    보안 네임 스페이스 구성 시작하기 :

    최소 구성이 필요합니다.

  2. ==============================

    2.Sean Patrick Floyd는 절대적으로 옳았습니다. 그러나 저에게 많은 시간을 투자 한 해결책을 언급할만한 가치가 있다고 생각합니다.

    Sean Patrick Floyd는 절대적으로 옳았습니다. 그러나 저에게 많은 시간을 투자 한 해결책을 언급할만한 가치가 있다고 생각합니다.

    @ImportResource 주석을 추가하기 만하면됩니다.

    @Configuration
    @EnableWebMvc
    @ComponentScan(basePackages = {"org.company"})
    @ImportResource({"classpath:security.xml"})
    public class CompanyWebMvcConfiguration extends WebMvcConfigurerAdapter {
    }
    

    security.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.2.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-3.1.xsd">
    
    
        <http use-expressions="true">
            <access-denied-handler error-page="/error"/>
        </http>
    

  3. ==============================

    3.Java 구성에서 다음 주석을 사용할 수 있습니다.

    Java 구성에서 다음 주석을 사용할 수 있습니다.

    @Configuration
    @EnableWebSecurity
    @EnableGlobalMethodSecurity
    public class MySecurityConfig extends WebSecurityConfigurerAdapter {
    
    }
    

    그러면 springSecurityFilterChain 빈을 정의하는 org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration 구성 클래스를 가져올 것이다.

  4. ==============================

    4.최소한의 구성으로 스프링 보안 파일을 제공하십시오.

    최소한의 구성으로 스프링 보안 파일을 제공하십시오.

    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.0.3.xsd">

    <http auto-config='true'>
        <intercept-url pattern="/**" access="ROLE_USER" />
    </http>
    

  5. from https://stackoverflow.com/questions/5090890/getting-error-org-springframework-beans-factory-nosuchbeandefinitionexception-n by cc-by-sa and MIT license