Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
';springSecurityFilterChain';抛出异常;嵌套异常为java.lang.IllegalArgumentException:提供程序列表不能包含空值_Java_Spring_Spring Mvc_Spring Security - Fatal编程技术网

';springSecurityFilterChain';抛出异常;嵌套异常为java.lang.IllegalArgumentException:提供程序列表不能包含空值

';springSecurityFilterChain';抛出异常;嵌套异常为java.lang.IllegalArgumentException:提供程序列表不能包含空值,java,spring,spring-mvc,spring-security,Java,Spring,Spring Mvc,Spring Security,在启动SpringBoot应用程序时,我不断发现以下错误 它与我的SpringWebSecurityConfig文件有关吗??下面是文件内容 @Configuration public class SpringWebSecurityConfig extends WebSecurityConfigurerAdapter { private AuthenticationProvider authenticationProvider; @Autowired @Qualifier("dao

在启动SpringBoot应用程序时,我不断发现以下错误

它与我的
SpringWebSecurityConfig
文件有关吗??下面是文件内容

@Configuration
public class SpringWebSecurityConfig extends WebSecurityConfigurerAdapter {
  private AuthenticationProvider authenticationProvider;

  @Autowired
  @Qualifier("daoAuthenticationProvider")
  public void setAuthenticationProvider(AuthenticationProvider authenticationProvider) {
    this.authenticationProvider = authenticationProvider;
  }

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

  @Bean("daoAuthenticationProvider")
  public AuthenticationProvider daoAuthenticationProvider(UserDetailsService userDetailsService) {
    DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setPasswordEncoder(passwordEncoder());
    provider.setUserDetailsService(userDetailsService);
    return provider;
  }

  @Autowired
  public void configureAuthManager(AuthenticationManagerBuilder authenticationManagerBuilder) {
    authenticationManagerBuilder.authenticationProvider(authenticationProvider);
  }

  @Override
  protected void configure(HttpSecurity httpSecurity) throws Exception {
    httpSecurity.authorizeRequests()
            .antMatchers("/").permitAll()
            /*.antMatchers("/","/products", "/product/show/*", "/console/*", "/h2-console/**")
                .permitAll().anyRequest().authenticated()*/
            .and()
                .formLogin().loginPage("/login")
                //.formLogin().loginPage("/login").successHandler(customSuccessHandler)
            .and()
                .logout().permitAll()
            .and()
                .exceptionHandling().accessDeniedPage("/error/403");


    httpSecurity.csrf().disable();
    httpSecurity.headers().frameOptions().disable();
  }
}
'''
异常堆栈跟踪:

2020-06-11 21:40:41.401  INFO 1240 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2020-06-11 21:40:41.403  WARN 1240 --- [  restartedMain] ConfigServletWebServerApplicationContext : **Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalArgumentException: providers list cannot contain null values**
2020-06-11 21:40:41.404  INFO 1240 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

2020-06-11 21:40:42.934  INFO 1240 --- [         task-1] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-06-11 21:40:42.944  INFO 1240 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-06-11 21:40:42.952  INFO 1240 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
Exception in thread "task-2" org.springframework.beans.factory.BeanCreationNotAllowedException: **Error creating bean with name 'springApplicationAdminRegistrar': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)**
    (...)
2020-06-11 21:40:43.183  WARN 1240 --- [  restartedMain] o.s.b.f.support.DisposableBeanAdapter    : Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-200]
2020-06-11 21:40:43.185  INFO 1240 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2020-06-11 21:40:43.200  INFO 1240 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2020-06-11 21:40:43.206  INFO 1240 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2020-06-11 21:40:43.232  INFO 1240 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-11 21:40:43.257 ERROR 1240 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

**org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalArgumentException: providers list cannot contain null values**
    (...)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalArgumentException: providers list cannot contain null values
    (...)
Caused by: java.lang.IllegalArgumentException: providers list cannot contain null values
    (...)

2020-06-11 21:40:43.265  WARN 1240 --- [  restartedMain] o.s.boot.SpringApplication               : Unable to close ApplicationContext

**org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springApplicationAdminRegistrar' defined in class path resource [org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available**
    (...)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available
    (...)
Caused by: **org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available
    (...)


Process finished with exit code 0
编辑:1

我确信这是@Bean(“daoAuthenticationProvider”)的原因。看起来这个bean要么在服务器启动时不可用,要么在它依赖于它之后被加载。我试图使用@DependsOn注释,但这会产生循环依赖性问题

下面是SpringJAR中引发此异常的部分。 org.springframework.security.authentication.ProviderManager#checkState

  private void checkState() {
        if (parent == null && providers.isEmpty()) {
            throw new IllegalArgumentException(
                    "A parent AuthenticationManager or a list "
                            + "of AuthenticationProviders is required");
        } else if (providers.contains(null)) {
            throw new IllegalArgumentException(
                    "providers list cannot contain null values");
        }
    }
请指导我,因为此问题会间歇性导致服务器启动失败