Madis Pärn (Migrated from SEC-3118) said:

GenericApplicationContext.setAllowCircularReferences(false) and @EnableWebSecurity together produce execption:

Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': 
Injection of autowired dependencies failed; 
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; 
nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1058E:(pos 1): A problem occurred when trying to resolve bean 'autowiredWebSecurityConfigurersIgnoreParents':'Could not resolve bean reference against BeanFactory'

Comment From: spring-projects-issues

Madis Pärn said:

Created testcase https://github.com/spring-projects/spring-framework-issues/pull/109

Comment From: spring-projects-issues

Rob Winch said:

Added attachment of the issue

Comment From: mgumerov

You really should have fixed that already. You, being a part of Spring project, essentially are disabling another core feature of Spring. Just because of you, I am not able to use it. I believe you could at least provide a quick-fix by injecting Provider< X> instead of X.

Comment From: marcusdacoregio

I tried to simulate the scenario using the @EnableWebSecurity annotation and setting the allowCircularReferences to false and I couldn't simulate it.

new SpringApplicationBuilder(SpringBootApp.class)
    .initializers((GenericApplicationContext c) -> c.setAllowCircularReferences(false))
    .run(args);

It seems to not be an issue anymore so I'm closing this, but if anyone is facing this issue we can reopen it.