Home > Back-end >  Intellij IDEA error - Could not autowire. No beans of 'HttpSecurity' type found
Intellij IDEA error - Could not autowire. No beans of 'HttpSecurity' type found

Time:06-28

I was trying out the following example in

https://github.com/lspil/blog/tree/master/endpoint-authorization-methods/spring-security-endpoint-authorization-new

and it works fine without any errors in Intellij IDEA. But as soon as I change the Spring Boot version from 2.4.4 to 2.7.1 in pom.xml, it throws an IDE error:

Could not autowire. No beans of 'HttpSecurity' type found for the following:

  @Bean
  public SecurityFilterChain configuration(HttpSecurity httpSecurity) throws Exception {
  ..........................

The application works fine but would be interested to know why this is happening. Version of IDE is IntelliJ IDEA 2022.1 (Ultimate Edition)

CodePudding user response:

For some reason, the IDE cannot detect that the HttpSecurity bean is configured by Spring Boot. You can get rid of the error by adding @EnableWebSecurity to your configuration class, it solves it because the annotation imports the HttpSecurityConfiguration configuration class.

I will bring this to the Spring Security team if there is a way to solve this problem on our side and will update the answer as soon as I have a position.

  • Related