Spring Security @ConditionalOnMissingBean评估delta

时间:2018-06-04 02:35:00

标签: java spring spring-security

为什么当我包含@EnableWebSecurity我的春季启动应用时会返回:

==========================
CONDITION EVALUATION DELTA
==========================


Positive matches:
-----------------

    None


Negative matches:
-----------------

   WebSecurityEnablerConfiguration:
      Did not match:
         - @ConditionalOnMissingBean (names: springSecurityFilterChain; SearchStrategy: all) found beans named springSecurityFilterChain (OnBeanCondition)
      Matched:
         - found ConfigurableWebEnvironment (OnWebApplicationCondition)


Exclusions:
-----------

    None


Unconditional classes:
----------------------

    None

但是当我在没有@EnableWebSecurity注释的情况下再次尝试时,我的春季启动应用程序在没有上述消息的情况下运行。

这是我的安全配置:

@Configuration
@EnableWebSecurity
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter{

    @Autowired
    private CustomUserDetailsService userDetailsService;

    @Bean
    public BCryptPasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }


    @Bean
    public DaoAuthenticationProvider authenticationProvider() {
        DaoAuthenticationProvider auth = new DaoAuthenticationProvider();
        auth.setUserDetailsService(userDetailsService);
        auth.setPasswordEncoder(passwordEncoder());
        return auth;
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
            auth.authenticationProvider(authenticationProvider());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {

            http
                    .authorizeRequests()
                        .antMatchers(
                                "/registration",
                                "/js/**",
                                "/css/**",
                                "/img/**",
                                "/webjars/**").permitAll()
                        .antMatchers("/admin/**").hasRole("ADMIN")
                        .anyRequest().authenticated()
                    .and()
                        .formLogin()
                            .loginPage("/login")
                                .permitAll()
                                .defaultSuccessUrl("/text")
                    .and()
                        .logout()
                            .invalidateHttpSession(true)
                            .clearAuthentication(true)
                            .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
                            .logoutSuccessUrl("/login?logout")
                    .permitAll()
                    .and()
                    .csrf().disable();
    }



}

0 个答案:

没有答案