eclipse, maven, 自动化部署web项目到tomcat

原理

将项目的src\main\webapp下的web相关文件及class文件一起复制到target下你在pom文件中配置的指定的文件夹中

tomcat配置用户

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

pom.xml配置

<project xmlns="http://maven.apache.org/POM/4.0.0"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.jje</groupId>
<artifactId>jjManage</artifactId>
<packaging>war</packaging>
<version>1.0</version>

<properties>
    <finalName>jj-czp</finalName> 
</properties>

<build>
    <plugins>
    <plugin>  
        <groupId>org.codehaus.mojo</groupId>  
        <artifactId>tomcat-maven-plugin</artifactId>  
        <configuration>  
            <url>http://localhost:8080/manager/html</url>  
            <username>admin</username>  
            <password>admin</password>  
            <path>/${finalName}</path>  
        </configuration>
    </plugin>
    <!--其他省略-->
    </plugins>
</build>

<dependencies>
<!--其他省略-->
</dependencies>

</project>   

最后

pom.xml右击Maven Build中填Goals: tomcat:redeploy

小鹏 wechat
公众号:数据Man
0%