Server

Tomcat 배포 방법 간단 정리

hamaganatanadda 2023. 6. 3. 16:29

tomcat version: apache-tomcat-9.0.55

war 파일로 배포

export -> war 

maven project는 maven build

 

※ maven build에서 생성 되는 war 파일과 export - war 구조는 거의 같지만 maven 프로젝트가 커지면 다를 수 있어 maven projcet는 maven build로 작업

 

export - war시 Optimize for a specific server runtime 체크 차이

-> 아무것도 하지 않는다고 한다

https://stackoverflow.com/questions/11759784/eclipse-war-export-optimize-for-a-specific-server-runtime

 

Eclipse war export: optimize for a specific server runtime

In eclipse, when exporting a web project to war/ear file there is this option "Optimize for a specific server runtime" What does happen under the hood when this option is selected? Couldn't fi...

stackoverflow.com

 

 

톰캣 conf - Server.xml 작업

<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" deployOnStartup ="false">
	<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log" suffix=".txt"/>
	<Context docBase="springex" path="/pathtest" reloadable="true" source="org.eclipse.jst.jee.server:springex"/>
</Host>

 

 

Host

appBase: 기본값은 webapps이다. 최상위 경로라고 보면 될 듯하다. webapps/test 로 하면 webapps/test 가 생성되고 해당 경로에서 작업 된다.

autoDeploy: war 파일이 변경되면 재배포한다.

unpackWARs: war 파일을 자동으로 풀 것인가

deployOnStartup: 기본적으로 없으나 추가 가능하다. 톰캣 시작 시 자동으로 war파일을 풀 것인가로 보이는데 정보가 많이 없고 path 사용 시 필요하다.

 

Context

docBase: springex.war가 있으면 springex폴더에 배포된다. 폴더 경로정도로 보면 될 듯 하다..

path: localhost:8080/pathtest 로 사용을 하고 싶을 때 넣으면 된다. 변경해서 사용할 경우 다른 옵션들을 false로 하지 않으면 이중 배포 되어 springex 폴더와 pathtest 폴더가 생긴다.

방법은 deployOnStartup과 autoDeploy값을 false로 하면 pathtest 폴더만 생긴다.

 

http://apieceofspace.blogspot.com/2018/09/spring-schedule.html

 

Spring 어플리케이션을 톰캣에 배포 하였을때 schedule 이 중복 실행 되는 현상

톰캣에 Spring 어플리케이션을 배포해서 서비스 하는 경우 schedule 이 중복되어 실행 되는 현상이 발생하는 경우가 있습니다. 이런 경우는 보통 어플리케이션이 이중으로 로딩되어 발생하는 현상

apieceofspace.blogspot.com

위 경로에서 1차로 이후 Reference에서 정확한 정보를 얻었다.

 

번역기:

처리할 적절한 웹 응용 프로그램을 선택하기 위해 각 요청 URI의 시작 부분과 일치하는 이 웹 응용 프로그램의 컨텍스트 경로입니다. 특정 호스트 내의 모든 컨텍스트 경로는 고유해야 합니다. 빈 문자열의 컨텍스트 경로("")를 지정하면 다른 컨텍스트에 할당되지 않은 모든 요청을 처리하는 이 호스트에 대한 기본 웹 응용 프로그램을 정의하는 것입니다.

이 특성은 server.xml에서 컨텍스트를 정적으로 정의할 때만 사용해야 합니다. 다른 모든 상황에서 경로는 .xml 컨텍스트 파일 또는 docBase에 사용된 파일 이름에서 유추됩니다.

server.xml에서 컨텍스트를 정적으로 정의하는 경우에도 docBase가 Host의 appBase 아래에 없거나 deployOnStartup 및 autoDeploy가 모두 false가 아니면 이 특성을 설정하면 안 됩니다. 이 규칙을 따르지 않으면 이중 배포가 발생할 수 있습니다.

 

reloadable: 배포 된 폴더에서 class 파일들이 변경되면 reload 할지이다. 부하 문제가 있을 수 있다.

https://stackoverflow.com/questions/68869467/is-it-possible-for-tomcats-autodeploy-to-redeploy-unpacked-directory

 

Is it possible for tomcat's autoDeploy to redeploy unpacked directory

I understand that a running Tomcat can redeploy web app if a new .WAR file is copied to webapps dir. However, in development mode, it is faster to just deploy compiled classes, and base on the docu...

stackoverflow.com

source: 이클립스 tool에서 외부 톰캣을 사용했을 경우 server.xml에서 해당 내용을 복사하면 따라온다. 툴에서 사용할 때만 필요하다.

https://okky.kr/questions/741854

 

OKKY - server.xml에서 얘가 하는 역할이 뭔가요?

<Context docBase="reportTest" path="/" reloadable="false" source="org.eclipse.jst.jee.server:reportTest"/> 저 source라는 녀석만 지우면 자꾸 에러가 뜨네요

okky.kr

 

 

 

Referecne에 대부분 나온다.

https://tomcat.apache.org/tomcat-9.0-doc/config/context.html

 

Apache Tomcat 9 Configuration Reference (9.0.75) - The Context Container

When autoDeploy or deployOnStartup operations are performed by a Host, the name and context path of the web application are derived from the name(s) of the file(s) that define(s) the web application. Consequently, the context path may not be defined in a M

tomcat.apache.org