SpringBootApplication - exclude autoconfigure

송형근·2024년 10월 7일
0

TIL

목록 보기
40/43
post-thumbnail

프로젝트에서 Common Module의 일부 패키지만 Component Scan에 추가했음에도 불구하고, 추가하지 않은 Redis 설정이 작동하는 이슈가 발생

추정 원인

project(':product-server') {
    dependencies {
        implementation project(':common')
    }
}
  • common 모듈을 implementation 하는 과정에서 Redis 설정이 Auto configure 돼서 발생하는 것으로 추정

해결

@SpringBootApplication(
        scanBasePackages = {
                "com.j1p3ter.productserver",
                "com.j1p3ter.common.auditing",
                "com.j1p3ter.common.response",
                "com.j1p3ter.common.exception",
                "com.j1p3ter.common.config.global"
        },
        exclude = {
                RedisAutoConfiguration.class
        }
)
public class ProductServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ProductServerApplication.class, args);
    }

}
  • ServerApplication에 SpringBootApplication 어노테이션 내에서 exclude를 사용해 RedisAutoconfiguration을 비활성화 시킴

P.S.

  • Spring Boot가 생각 이상으로 많은 부분을 자동으로 설정 해준다는걸 다시금 느끼게 되었음
profile
기록을 남겨보자

0개의 댓글