您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“maven怎么發(fā)布war包到tomcat中”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“maven怎么發(fā)布war包到tomcat中”吧!
先在本地將代碼打成 war 包,然后調(diào)用tomcat的接口 *
${host}/manager/text
接口將war包上傳到tomcat的webapp
*目錄下,重啟tomcat即可
配置tomcat權(quán)限,使可以可以通過(guò)接口方式傳war包
配置tomcat允許訪問(wèn)的ip地址
在maven的setting中配置tomcat的用戶名密碼等信息
在maven的pom.xml中配置maven的地址以及發(fā)布項(xiàng)目名稱
編輯tomcat 配置文件
${Catalina_home}/con/tomcat_users.xml
,配置權(quán)限如下:
<role rolename="manager-gui"/> <role rolename="manager-script"/> <user username="tomcat" password="gui" roles="manager-gui"/> <user username="deploy" password="deploy" roles="manager-gui,manager-script"/>
manager-gui 表示 允許訪問(wèn)html接口(即URL路徑為/manager/html/) manager-script 表示 允許訪問(wèn)純文本接口(即URL路徑為/manager/text/)
編輯tomcat 配置文件
${Catalina_home}/webapp/manager/META-INF/context.xml
,將context節(jié)點(diǎn)下的*<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
*注釋掉,結(jié)果如下:
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <Context antiResourceLocking="false" privileged="true" > <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> --> <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/> </Context>
tomcat
的用戶名密碼等信息編輯 maven 中的setting文件,在servers節(jié)點(diǎn)中添加一個(gè)server子節(jié)點(diǎn)如下:
<servers> <server> <id>tomcat-maven</id> <username>deploy</username> <password>deploy</password> </server> </servers>
編輯 maven 中的pom.xml文件,早plugins中添加plugin節(jié)點(diǎn):
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> <configuration> <server>tomcat-maven</server> <url>http://30.23.76.63:8080/manager/text</url> <!--注釋:該鏈接適用的角色為tomcat7中設(shè)置的manager-script--> <path>/${finalName}</path> </configuration> </plugin>
server 必須和第三步中id的值保持一致
到目前為止配置工作已經(jīng)完成,只需打包并發(fā)布即可
發(fā)布方式:只需要在maven打包命令后加上
tomcat7:redeploy
命令即可,如下:
mvn package -Dmaven.test.skip=true tomcat7:redeploy
到此,相信大家對(duì)“maven怎么發(fā)布war包到tomcat中”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。