• Maven -Maven配置tomcat插件 两种


    Maven Tomcat插件现在主要有两个版本,tomcat-maven-plugintomcat7-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

    ---------------------------------------------------------------------------------------------------

    1tomcat-maven-plugin 插件使用

    pom.xml中加入下面代码:

       <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>tomcat-maven-plugin</artifactId>
                    <version>1.1</version>
                    <configuration>
                        <path>/wp</path>
                        <port>8080</port>
                        <uriEncoding>UTF-8</uriEncoding>
                        <url>http://localhost:8080/manager/html</url>
                        <server>tomcat6</server>
                    </configuration>
                </plugin>

    简要说明一下:

    path  是访问应用的路径

    port tomcat 的端口号

    uriEncoding  URLUTF-8进行编码,这样就解决了中文参数乱码。

    Server 指定tomcat名称。

    如果Eclipse 安装了Maven插件,选 择pom.xml文件,击右键——>选择 Run As——> Maven build 。(如果为安装插件,请查看博文eclipse安装maven插件

    如果是第一次运行,会弹出下面对话框。在Goals框加加入以下命令: tomcat:run

    这样Tomcat 插件就可以运行。

    下面介绍几个常用的Goal

    tomcat:deploy   --部署一个web war包
    tomcat:reload   --重新加载web war包
    tomcat:start    --启动tomcat
    tomcat:stop    --停止tomcat
    tomcat:undeploy--停止一个war包
    tomcat:run  启动嵌入式tomcat ,并运行当前项目

    2tomcat7-maven-plugin 插件使用

    在pom.xml中加入下面代码:
    <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                   <configuration>
                      <path>/</path>
                      <port>8080</port>
                      <server>tomcat7</server>
                   </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                    </executions>
            </plugin>

    在这里要注意一下,该插件命名方式有些不同,比如启动tomcat ,对应的目标命令是: tomcat7:run ,同样,其它命令也是这样,需要更改为:tomcat7<插件执行点>

    tomcat7:deploy  --部署一个web war包
    tomcat7:reload  --重新加载web war包
    tomcat7:start    --启动tomcat
    tomcat7:stop    --停止tomcat
    tomcat7:undeploy--停止一个war包
    tomcat7:run 启动嵌入式tomcat ,并运行当前项目
    如果需要debug,就使用debug as 方式启动项目!
  • 相关阅读:
    在Eclipse中设置中文JavaDOC
    买车,给点建议和意见
    父亲节
    JSP文件上传

    昨天我生日
    换皮了
    西安夕阳
    WinForms中只能输入数字的文本框
    使用GoogleCode SVN服务
  • 原文地址:https://www.cnblogs.com/JBLi/p/10562570.html
Copyright © 2020-2023  润新知