Exception in thread "main" java.lang.IllegalAccessError: class org.springframework.boot.SpringApplication tried to access private method
'java.util.List org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames(java.lang.Class, java.lang.ClassLoader)'
(org.springframework.boot.SpringApplication and org.springframework.core.io.support.SpringFactoriesLoader are in unnamed module of loader 'app')
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:423)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:417)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:272)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:253)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236)
at com.terzeron.grammar.Application.main(Application.java:9)
java.lang.IllegalAccessError: class org.springframework.boot.SpringApplication tried to access private method 'java.util.List org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames(java.lang.Class, java.lang.ClassLoader)' (org.springframework.boot.SpringApplication and org.springframework.core.io.support.SpringFactoriesLoader are in unnamed module of loader 'app')
에러가 발생하는 이유는 Spring Boot Application이 spring-boot-starter-parent를 상속받지 않았기 때문이다.
해결 방법은 pom.xml에 <parent>를 지정하는 것이다.
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.12.RELEASE</version>
</parent>