天天看點

Maven 內建Tomcat插件tomcat-maven-plugin  插件使用

在pom.xm 加入以下xml。

<code>&lt;</code><code>plugin</code><code>&gt;</code>

<code>                </code><code>&lt;</code><code>groupId</code><code>&gt;org.apache.tomcat.maven&lt;/</code><code>groupId</code><code>&gt;</code>

<code>                </code><code>&lt;</code><code>artifactId</code><code>&gt;tomcat7-maven-plugin&lt;/</code><code>artifactId</code><code>&gt;</code>

<code>                </code><code>&lt;</code><code>version</code><code>&gt;2.1&lt;/</code><code>version</code><code>&gt;</code>

<code>                </code><code>&lt;</code><code>configuration</code><code>&gt;</code>

<code>                    </code><code>&lt;</code><code>port</code><code>&gt;9090&lt;/</code><code>port</code><code>&gt;</code>

<code>                    </code><code>&lt;</code><code>path</code><code>&gt;/mgr&lt;/</code><code>path</code><code>&gt;</code>

<code>                    </code><code>&lt;</code><code>uriEncoding</code><code>&gt;UTF-8&lt;/</code><code>uriEncoding</code><code>&gt;</code>

<code>                    </code><code>&lt;</code><code>finalName</code><code>&gt;mgr&lt;/</code><code>finalName</code><code>&gt;</code>

<code>                    </code><code>&lt;</code><code>server</code><code>&gt;tomcat7&lt;/</code><code>server</code><code>&gt;</code>

<code>                </code><code>&lt;/</code><code>configuration</code><code>&gt;</code>

<code>            </code><code>&lt;/</code><code>plugin</code><code>&gt;</code>

簡要說明一下:

path  是通路應用的路徑

port 是tomcat 的端口号

uriEncoding  URL按UTF-8進行編碼,這樣就解決了中文參數亂碼。

Server 指定tomcat名稱。

配置就這麼簡單,基本搞掂,下面看看如何使用。

這樣Tomcat 插件就可以運作。

下面介紹幾個常用的Goal

指令

描述

tomcat:deploy

部署一個web war包

tomcat:reload

重新加載web war包

tomcat:start

啟動tomcat

tomcat:stop

停止tomcat

tomcat:undeploy

停止一個war包

tomcat:run

啟動嵌入式tomcat ,并運作目前項目

本文轉自yunlielai51CTO部落格,原文連結:http://blog.51cto.com/4925054/1709973,如需轉載請自行聯系原作者