tomcat7-maven-plugin 예제

tomcat7-maven-plugin은 별도의 tomcat서버를 설치하지 않고 maven 실행만으로 개발중인 웹 애플리케이션을 tomcat7에서 실행할 수 있다.
eclipse 웹 프로젝트를 마우스 오른쪽 버튼을 클릭 > Run As > 5 Maven Build... 를 선택한다.
maven tomcat8 plugin 01
Edit Configuration > Goals에서 tomcat7:run을 입력하고 Run버튼을 선택하면 별도의 eclipse 설치 없이 tomcat서버를 실행하고 웹 애플리케이션을 배포한다.
maven tomcat8 plugin 02 eclipse상에서 실행할 수도 있지만 CLI(Command Line Interface)-도스창 에서도 실행할 수 있다. 프로젝트의 POM.xml이 존재하는 디렉토리에서 mvn tomcat7:run을 입력하고 Enter키를 치면 tomcat서버 실행 및 웹 애플리케이션이 배포된다. maven tomcat8 plugin 03
아래는 tomcat7-maven-plugin을 실행하기 위한 POM.xml에 등록할 예제이다.
line 09 : tomcat서버를 8888 port 에서 실행
line 10 : root context에 배포
line 12 : jvm heap size를 최대 1024M 최소 1024M, PermSize를 최대 512로 설정
<build>
    <plugins>

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <port>8888</port>
                <path>/</path>
                <systemProperties>
                	<JAVA_OPTS>-Xms1024m -Xmx1024m --XX:MaxPermSize=512m</JAVA_OPTS>
                </systemProperties>
            </configuration>
        </plugin>

    </plugins>
</build>
Goal Description
 tomcat7:deploy Deploy a WAR to Tomcat.
 tomcat7:deploy-only Deploy a WAR to Tomcat without forking the package lifecycle
 tomcat7:exec-war
 This mojo will create a self executable jar file containing all tomcat classes.
So you will be able to use only: java -jar createjar.jar to run your webapp without need to install an Apache Tomcat instance.
More details here: http://tomcat.apache.org/maven-plugin-2.0-beta-1/executable-war-jar.html
tomcat7:exec-war-only No description.
 tomcat7:help Display help information on tomcat7-maven-plugin.
 Call mvn tomcat7:help -Ddetail=true -Dgoal= to display parameter details.
 tomcat7:run Runs the current project as a dynamic web application using an embedded Tomcat server.
 tomcat7:run-war Runs the current project as a packaged web application using an embedded Tomcat server.
 tomcat7:run-war-only Runs the current project as a packaged web application using an embedded Tomcat server without forking the package cycle.
 tomcat7:shutdown
 Shuts down all possibly started embedded tomcat servers. This will be automatically down through a shutdown hook or you may call this Mojo to shut them down explictly.
By default the shutdown goal is not bound to any phase. For integration tests you might want to bind it to post-integration-test.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다