Jit_Log

[Visual Studio Code] Tomcat 서버 설치하기 본문

IT 공부/개발툴

[Visual Studio Code] Tomcat 서버 설치하기

준발이오 2024. 11. 9. 12:38

들어가기 전

학교 과제로 인해 간단한 JSP 페이지를 실행해야 하는 상황이 생겼습니다. 이클립스를 설치하여 A부터 구축하는 건 시간을 너무 잡아먹을 것 같아, VSCode에 작업 환경을 구성했습니다. 여러 블로그를 참고하여 기록했습니다.

 

설치 환경은 다음과 같습니다.

설치 환경
HostOS: Windows 11 Home
Tool: JAVA (JDK 17)
IDE: Visual Studio Code

VSCode 확장 프로그램 설치

VSCode에서 톰캣 서버를 실행하기 위해선 Debugger for java와 Tomcat for java를 설치해야 한다고 합니다. 

Debugger for java: 자바 애플리케이션을 디버그하기 위한 확장자입니다. 해당 확장자를 사용하면 톰캣 서버가 실행되는 동안 디버깅 명령어를 이용해 자바코드 한 줄씩 분석할 수 있습니다.

 

하지만 VSCode에서 Tomcat for java는 지원이 종료되었고, Community Server Connectors를 설치하라고 안내합니다. 설치를 위해 안내대로 설치합니다.

 

 

설치 후 탐색기로 돌아가면 SERVERS에 Community Server Connector가 나타납니다. 우클릭을 하여 확장프로그램을 실행 해줍니다.

 

PC에 따로 Tomcat이 설치되어 있지않아서, 프로그램에서 지원해주는 서버를 사용하기 위해 Yes를 눌러줍니다. 

 

가장 익숙한 Apache Tomcat 9.xx 로 설정했습니다.

 

Apache License 관련 허용 팝업입니다. Continue > Yes (True)

 

Tomcat 서버가 설치된 걸 확인할 수 있습니다.

 

서버 수정을 위해 어디에 위치해 있는지 확인해봅니다. 우클릭 > Edit Server 를 통해 확인하여 server.base.dir 경로를 따라 들어갑니다.

ex) C:\Users\{사용자 계정}\.rsp\redhat-community-server-connector\runtimes\installations\tomcat-9.0.41\apache-tomcat-9.0.41

 

서버를 실행하면 한글이 깨져서 나오기 때문에 logging.properties 파일을 수정해줍니다.

UTF-8 > EUC-KR

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.org.apache.juli.AsyncFileHandler.level = FINE
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
1catalina.org.apache.juli.AsyncFileHandler.maxDays = 90
1catalina.org.apache.juli.AsyncFileHandler.encoding = EUC-KR

2localhost.org.apache.juli.AsyncFileHandler.level = FINE
2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
2localhost.org.apache.juli.AsyncFileHandler.maxDays = 90
2localhost.org.apache.juli.AsyncFileHandler.encoding = EUC-KR

3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
3manager.org.apache.juli.AsyncFileHandler.maxDays = 90
3manager.org.apache.juli.AsyncFileHandler.encoding = EUC-KR

4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
4host-manager.org.apache.juli.AsyncFileHandler.maxDays = 90
4host-manager.org.apache.juli.AsyncFileHandler.encoding = EUC-KR

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
java.util.logging.ConsoleHandler.encoding = EUC-KR


############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler

# For example, set the org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = FINE

# To see debug messages in TldLocationsCache, uncomment the following line:
#org.apache.jasper.compiler.TldLocationsCache.level = FINE

# To see debug messages for HTTP/2 handling, uncomment the following line:
#org.apache.coyote.http2.level = FINE

# To see debug messages for WebSocket handling, uncomment the following line:
#org.apache.tomcat.websocket.level = FINE

 

마지막으로 서버 우클릭 > Start Server를 해주면 정상적으로 Tomcat이 실행되는 걸 확인할 수 있습니다.

작동 확인: http://localhost:8080