maven部署tomcat7

一、修改項目pom.xmlweb

在project節點下,添加tomcat-maven-plugin插件信息,配置好tomcat管理賬號和密碼apache

<plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <server>tomcat7</server>
                    <port>8082</port>
                    <path>/Openoa</path>
                    <url>http://localhost:8082/manager/text</url>
                    <username>tomcat</username>
                    <password>123456</password>
                    <uriEncoding>UTF-8</uriEncoding>
                </configuration>
                <executions>
                    <execution>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>tomcat

二、修改(tomcat)server下tomcat-users.xml文件 給tomcat 添加管理員maven

<role rolename="manager-script"/>
<role rolename="manager-gui"/>
<user username="tomcat" password="123456" roles="manager-script , manager-gui"/>測試

三、啓動tomcat,發佈項目ui

新建maven build 在Goals下輸入:tomcat7:deploy -Dmaven.test.skip=trueurl

大意爲在tomcat下部署,部署過程當中忽略測試路徑插件

Base directory:爲項目路徑,使用debug或run運行debug

當控制檯出現以下字樣表示部署成功調試

四、關閉tomcat、使用maven命令運行tomcat

新建maven build 在Goals下輸入:tomcat7:run -Dmaven.surefire.debug

大意爲 運行tomcat7 啓用調試

配置如圖

配置好後使用debug運行,這樣就可在tomcat中發佈並調試web項目了

運行後 如出現以下等字樣又無出現運行時異常,表示部署成功了

相關文章
相關標籤/搜索