maven集成tomcat插件以及乱码解决

Maven已经是Java的项目管理标配,如何在JavaEE开发使用Maven调用Web应用,是很多同学关心的问题。本文将介绍,Maven如何介绍Tomcat插件。

Maven Tomcat插件现在主要有两个版本,tomcat-maven-plugin和tomcat7-maven-plugin,使用方式基本相同。

tomcat-maven-plugin 插件官网:http://mojo.codehaus.org/tomcat-maven-plugin/plugin-info.html。

tomcat7-maven-plugin 插件官网:http://tomcat.apache.org/maven-plugin.html。

 

tomcat7-maven-plugin 插件使用

配置

在pom.xm 加入以下xml。

<plugin>
        groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <version>1.1</version>
               <configuration>
<!--path  是访问应用的路径--> <path>/wp</path>
<!--port 是tomcat 的端口号c--> <port>8080</port>
<!--uriEncoding  URL按UTF-8进行编码,这样就解决了中文参数乱码--> <uriEncoding>UTF-8</uriEncoding> <url>http://localhost:8080/manager/html</url>
<!--Server 指定tomcat名称。-->
<server>tomcat7</server>
</configuration>
</plugin>

  

插件运行


如果Eclipse 安装了Maven插件,选 择pom.xml文件,击右键——>选择 Run As——> Maven build -->输入 tomcat7:run -->单击run运行。

 这样tomcat7就可以正常运行了。

 

下面介绍几个常用的Goal

命令 描述
tomcat:deploy 部署一个web war包
tomcat:reload 重新加载web war包

tomcat:start

启动tomcat

tomcat:stop

停止tomcat

tomcat:undeploy

停止一个war包
tomcat:run 启动嵌入式tomcat ,并运行当前项目

   

tomcat-maven-plugin 插件使用与tomcat7-maven-plugin 插件使用一致,只要把<server>tomcat7</server>改为<server>tomcat7</server>即可


posted @ 2016-12-08 14:48  迷.梦  阅读(5212)  评论(0编辑  收藏  举报