본문 바로가기

Dev/Spring

springBoot - 내부톰캣 제외시 [class file for jakarta.servlet.ServletException not found] Feat.Gradle

728x90
반응형

스프링부트로 설정 후 내부 톰캣을 제외하니 에러가..

아!

springboot 3.1.4 에서 세팅 내용입니다.

 

내부 톰캣을 제외 하기 위해 Gradled에 톰캣 제외 문구 추가

implementation ('org.springframework.boot:spring-boot-starter-web') {
		exclude module: 'spring-boot-starter-tomcat'
	}

 

추가 후 빌드를 하면.. 오류가!!!!

ServletInitializer.java:6: error: cannot access ServletException
public class ServletInitializer extends SpringBootServletInitializer {
       ^
  class file for jakarta.servlet.ServletException not found
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
> Run with --info option to get more log output.
> Run with --scan to get full insights.

BUILD FAILED in 743ms
1 actionable task: 1 executed

하!! 한번에 되는게 없구나!!

 

반응형

 

이유는 톰캣을 제거 하면서 servlet관련으로 문제가 생겨서 에러가 발생

 

처리 방법으로 gradle에 아래 문구 추가!!

implementation 'jakarta.servlet:jakarta.servlet-api'

문제없이 빌드 해결!!

 

728x90
반응형