码迷,mamicode.com
首页 > 其他好文 > 详细

maven项目自动打包部署到tomcat中

时间:2015-07-11 13:31:07      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:

1. 在eclipse配置tomcat,部署路径设置为tomcat的webapps目录下。

2.修改tomcat-users.xml

  <!-- Tomcat 6.x 系列-->

  <role rolename="manager"/> 

    <user password="admin" roles="manager" username="admin"/>

 <!-- Tomcat 7.x 系列-->

 <role rolename="manager"/> 

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

3.maven的settings.xml 文件打开,写入用户名和密码

<servers>
<server>
<id>tomcat</id>
<username>admin</username>
<password>pass!@#</password>
</server>
</servers>

 

 

4.pom文件为:

<build>
        <finalName>dounine-frame</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat6-maven-plugin</artifactId>
                <version>2.0</version>
                <configuration>
                    <!-- Tomcat 6.x -->
                    <url>http://localhost:8080/manager/</url>
                     <!-- Tomcat 7.x -->
                     <!-- <url>http://localhost:8080/manager/text</url> -->
              <server>tomcat</server> <!-- 这个server标签里面的值(tomcat)要和你的setting.xml里面的id的值(tomcat)一致-->
                    <username>admin</username>
                    <password>admin</password>
                    <path>/dounine-frame</path>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>*.*</include>
                </includes>
            </resource>
        </resources>
    </build>

5.启动tomcat

6.在eclipse中:tomcat6.x使用 tomcat6:redeploy。

maven项目自动打包部署到tomcat中

标签:

原文地址:http://www.cnblogs.com/dapeng520/p/4638366.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!