inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

inyang님의 게시글

inyang inyang

@inyang3064

수강평 작성수
-
평균평점
-

게시글 1

질문&답변

EmbedTomcatServletMain 실행 시 발생하는 오류

안녕하세요. 저도 같은 문제가 있었는데 아래 두가지 방법 중 하나로 해결했습니다. 환경은 Windows 에 IntelliJ 였습니다. #1 특정 폴더 생성하여 해결 에러 리스트 두번째 줄에 나오는 내용을 보고 tomcat:8080 아래에 webapps 폴더 추가 후 실행 Caused by: java.lang.IllegalArgumentException: The main resource set specified [D:\Spring_boot_edu\boot-source-20230228\start\embed\tomcat.8080\webapps\] is not valid #2 pdf 교재 (3.스프링 부트와 내장 톰캣.pdf) 에서 추가하는 코드를 넣어서 해결 했습니다. //서블릿 등록 Context context = tomcat.addContext("", "/"); //== 코드 추가 시작== File docBaseFile = new File(context.getDocBase()); if (!docBaseFile.isAbsolute()) { docBaseFile = new File((( org.apache.catalina.Host ) context.getParent()).getAppBaseFile(), docBaseFile.getPath()); } docBaseFile.mkdirs(); //== 코드 추가 종료== tomcat.addServlet("", "helloServlet", new HelloServlet()); context.addServletMappingDecoded("/hello-servlet", "helloServlet"); tomcat.start(); 잘 해결 되시기 바랍니다. ^^

좋아요수
0
댓글수
3
조회수
1334