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.NullPointerException
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.NullPointerException
Caused by: java.lang.NullPointerException: null
스프링 시큐리티를 적용하다 보면 아래와 같은 오류를 접하긴 하곤 한다.
springSecurityFilterChain를 찾지 못했기 때문에 정의할수 없다
(하위 기능들을 이용할수 없다.)
어떤 분께서는 @Autowired 대신 lombok기능중에 하나인 @AllArgsConstructor 적용했더니 됬다고는 하는데...
사용자의 환경설정이 제각각이고 적용방식이 전부 다르다.
그래서 원인을 찾기가 여려운데 그중에서도 해결책이 간혹 보이기도 해서 기록삼아 적어둔다.
1. Dependency 추가.
주로 자바 11버전에서 문제가 발생한다고 해서 바로 적용해봤는데 해결되진 않았다.(내 환경에서)
2. ComponantSacn 직접 지정.
security 패키지를 못찾는지 ComponantScan해주면 security 하위패키지를 전부 찾아준다.
그래도 또 언제 이와 같은 문제가 발생할수 있으니 기록해둔다.
1. Dependency 추가.
1) maven
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.1</version>
</dependency>
2) gradle
implementation 'com.sun.xml.bind:jaxb-core:2.3.0.1'
implementation 'javax.xml.bind:jaxb-api:2.3.1'
implementation 'com.sun.xml.bind:jaxb-impl:2.3.1'
2. ComponantSacn 직접 지정.

security 패키지 하위에 있는 설정들 전부를 직접 스캔 해버리는 방식으로 문제를 해결했다.
# 환경
spring boot 2.4.x
gradle
java 11
intellij
############
#도움 받은 출처
############
https://blog.csdn.net/qq_37736010/article/details/104894948
springboot项目中运行spring security 报 Error creating bean with name 'springSecurityFilterChain'。。。。错误_职场
springboot版本:1.5.9 spring security版本:1.5.9 问题描述: 启动springboot项目,直接编译报错,内容: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in cla
blog.csdn.net
[Spring Error] springSecurityFilterChain 에러 해결 방법
springSecurityFilterChain 에러 해결 방법 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain'defined in class path resource [org/springf..
loosie.tistory.com