网上文章不少坑,终于在官方文档找到些苗头。

1、配置pom.xml文件,增加一个pulgin,官方文档 http://tomcat.apache.org/maven-plugin-2.2/

            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <url>http://localhost:8080/manager/text</url>
                    <server>TomcatServer</server>
                </configuration>
            </plugin>

2、修改mvn配置文件,/etc/maven/settings.xml,增加一台TomcatServer服务器

    <server>
        <id>TomcatServer</id>
        <user>admin</user>
        <password>admin</password>
    </server>

3、修改tomcat用户配置文件,增加admin这个用户,并赋予它manager-gui跟manager-script这两个角色。我的配置文件位于/usr/local/tomcat/conf/tomcat-users.xml

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="admin" roles="manager-gui,manager-script"/>

4、启动tomcat,默认URL: http://localhost:8080

5、执行mvn部署命令, 官方文档 http://tomcat.apache.org/maven-plugin-2.2/context-goals.html

mvn package tomcat7:redeploy

大功告成

[INFO] tomcatManager status code:200, ReasonPhrase:OK
[INFO] OK - Deployed application at context path /simple-service-webapp
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 55.952 s
[INFO] Finished at: 2015-06-20T22:22:28+08:00
[INFO] Final Memory: 16M/180M
[INFO] ------------------------------------------------------------------------

 

By charlie

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注