我正在尝试按如下方式自动装配FilterChainProxy实例:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private FilterChainProxy filterChainProxy;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.addFilterAfter( new CustomSecurityFilter(), BasicAuthenticationFilter.class);
}
}
我收到以下异常:
Sep 22 20:08:16 xxxxxx java[21355]: 2017-09-22 20:08:16.953 WARN 21355 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfig': Unsatisfied dependency expressed through field 'filterChainProxy'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.web.FilterChainProxy' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
我把FilterChainProxy实例放在哪个类中并不重要。 我不使用XML来配置我的应用程序,所有Spring配置都是基于注释的。 如何解决这个问题?