国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Tomcat > 正文

SSM項目頻繁打成war包部署,使用tomcat和maven實現熱部署配置

2024-09-06 19:00:58
字體:
來源:轉載
供稿:網友

背景

眾所周知,我們平時將JavaEE項目開發完后,需要將項目部署到服務器的tomcat上。常用的部署方式是將項目打包成war包放到tomcat的webapps下,然后重啟tomcat,然后通過ip地址+端口號訪問。這樣部署本身是沒問題的,但問題在于,如果還是在生產環境下的話,需要頻繁的更改優化項目,那么就需要頻繁的將項目打war包,替換webapps下的war包,操作繁瑣。

接下來我們講述如何實現本地編程,然后部署項目到遠程服務器的tomcat上,實現熱部署。

所用技術&工具

maven(項目構建和依賴管理) tomcat7插件 (部署到tomcat的插件) tomcat服務器 (web服務器) 編譯器推薦使用IDEA

1.確保本地具有遠程tomcat的使用權限

修改Tomcat下{TOMCAT_HOME}conf/tomcat-users.xml配置文件,添加用戶名、密碼、權限。

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

2.配置Tomcat允許遠程訪問

在遠程服務器的{TOMCAT_HOME}conf/Catalina/localhost/目錄下創建一個manager.xml文件,配置如下內容:

<?xml version="1.0" encoding="UTF-8"?><Context privileged="true" antiResourceLocking="false" docBase="${catalina.home}/webapps/manager">     <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" /></Context>

注:如果只想部分用戶使用,可在allow配置IP,例如

allow="192.168.0.102"

3.重啟遠程Tomcat

在tomcat的bin目錄下依次執行

//關閉tomcat./shutdown.sh//啟動tomcat./startup.sh

4.測試是否具有使用權限

訪問tomcat,例如http://192.168.0.102:8080(使用自己的服務器或是虛擬機的ip地址)
點擊Manager APP


在這里插入圖片描述

輸入剛才配置的tomcat的賬號和密碼

在這里插入圖片描述

如果跳轉到這個頁面證明配置完成

在這里插入圖片描述

當然也可以在當前頁面實現war的部署和替換,這也是另一種部署方式,不過依然沒有熱部署方便

問題:如果出現403報錯如下

403 Access DeniedYou are not authorized to view this page. By default the Manager is only accessible from a browser running on the same machine as Tomcat. If you wish to modify this restriction, you'll need to edit the Manager's context.xml file. If you have already configured the Manager application to allow access and you have used your browsers back button, used a saved book-mark or similar then you may have triggered the cross-site request forgery (CSRF) protection that has been enabled for the HTML interface of the Manager application. You will need to reset this protection by returning to the main Manager page. Once you return to this page, you will be able to continue using the Manager application's HTML interface normally. If you continue to see this access denied message, check that you have the necessary permissions to access this application. If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 辽宁省| 德化县| 麦盖提县| 普宁市| 满城县| 视频| 准格尔旗| 彰化市| 太和县| 突泉县| 光山县| 禄丰县| 台江县| 白银市| 乌苏市| 拉孜县| 霍城县| 上栗县| 大埔区| 甘孜县| 兴化市| 什邡市| 额尔古纳市| 泰兴市| 屏山县| 金溪县| 永兴县| 盐源县| 灵山县| 凌云县| 九龙城区| 鄂伦春自治旗| 通山县| 城口县| 临泉县| 淳化县| 长治市| 资兴市| 兴义市| 资兴市| 苍南县|