15.自动部署web工程

用maven自动部署web工程

在pom.xml中写入以下:

<build>
    <!--最终名称,进入网页时有http://localhost:8080/xxx/-->
    <finalName>xxx</finalName>
    <!--配置插件-->
    <plugins>
        <plugin>
            <!--cargo是一家专门从事“启动Servlet容器”的组织-->
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.2.3</version>
            <!--设置插件-->
            <configuration>
                <!--配置容器位置-->
                <container>
                    <containerId>tomcat9.0.2</containerId>
                    <home>D:\tomcat-9.0.2</home>
                </container>
                <configuration>
                    <!--做确认-->
                    <type>existing</type>
                    <home>D:\tomcat-9.0.2</home>            
                    <!--配置端口号,默认8080不用配置-->
                    <properties>
                        <cargo.servlet.port>8888</cargo.servlet.port>
                    </properties>
                </configuration>
            </configuration>

            <!--配置插件在什么情况下执行-->
            <executions>
                <execution>
                    <id>cargo-run</id>                  
                    <!--生命周期的阶段-->
                    <phase>install</phase>
                    <goals>
                        <!--插件目标-->
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

之后在maven中用mvn -deploy执行

猜你喜欢

转载自blog.csdn.net/yztfst/article/details/82504202