title: Spring boot 2.6.0 Error creating bean with name 'webSecurityConfig'
body: <p>I am unable to update my spring boot app to 2.6.0 from 2.5.7. It throws the following error.</p>
  <pre><code>2021-12-07T08:40:22,311 ERROR [restartedMain] o.s.b.SpringApplication.reportFailure:819|| Application run failed org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'webSecurityConfig': 
  The requested bean is currently in creation: Is there an unresolvable circular reference?
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:355)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:227)
  </code></pre>
  <p>From the spring-boot 2.6.0 release notes, it is clear that circular references are disabled. And it can be enabled back with the property <code>spring.main.allow-circular-references = true</code>. But I would like to fix the circular reference in the first place. Can anyone help me troubleshoot this issue? Please find the <strong>WebSecurityConfig</strong> class below,</p>
  <pre class="lang-java prettyprint-override"><code>@Configuration
  @EnableWebSecurity
  @SuppressWarnings({&quot;PMD.SignatureDeclareThrowsException&quot;})
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
      private final UserDetailsService userDetailsService;
  
      public WebSecurityConfig(final UserDetailsService userDetailsService) {
          this.userDetailsService = userDetailsService;
      }
  
      @Bean
      public BCryptPasswordEncoder bcryptPasswordEncoder() {
          return new BCryptPasswordEncoder();
      }
  
      @Override
      protected void configure(final HttpSecurity http) throws Exception {
          http
                  .authorizeRequests()
                      .antMatchers(&quot;/resources/**&quot;, &quot;/registration&quot;, &quot;/css/**&quot;, &quot;/js/**&quot;, &quot;/h2-console/*&quot;).permitAll()
                      .anyRequest().authenticated().and()
                  .formLogin()
                      .loginPage(&quot;/login&quot;).permitAll().and()
                  .headers()
                      .frameOptions().sameOrigin().and()
                  .logout()
                      .permitAll().and()
                  .requiresChannel()
                      .requestMatchers(r -&gt; r.getHeader(&quot;X-Forwarded-Proto&quot;) != null)
                      .requiresSecure();
      }
  
      @Autowired
      public void configureGlobal(final AuthenticationManagerBuilder auth) throws Exception {
          auth.userDetailsService(userDetailsService).passwordEncoder(bcryptPasswordEncoder());
      }
  }
  </code></pre>
  <p>My code is open-sourced and can be found at <a href="https://github.com/surajcm/Poseidon" rel="noreferrer">https://github.com/surajcm/Poseidon</a>, I will try to troubleshoot on my own and will share the updates if I am able to resolve this issue</p>