tomcat配置熱部署(maven插件配合熱部署)

1、熱部署是指在tomcat運行的時候發佈新的web項目到tomcat上,使用tomcat後臺進行項目的熱部署發佈,訪問http://ipaddr:8080


2、訪問後臺的時候我們需要進行登錄驗證,這裏我們需要配置用戶(如果訪問了點擊取消,會出現401未授權頁面,上面有用戶的相關配置)


3、配置tomcat後臺用戶說明,步驟如下:(第4步爲具體配置)

1)找到這個文件 conf/tomcat-users.xml

2)配置後臺網頁版用戶的權限(例子)

<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
3)配置權限說明

manager-gui - allows access to the HTML GUI and the status pages

manager-script - allows access to the text interface and the status pages

manager-jmx - allows access to the JMX proxy and the status pages

manager-status - allows access to the status pages only  

求助了谷歌大神:2333

manager-gui - 允許訪問HTML GUI和狀態頁面

manager-script - 允許訪問文本界面和狀態頁面

manager-jmx - 允許訪問JMX代理和狀態頁面

manager-status - 僅允許訪問狀態頁面

4)我們如果用到了maven的熱部署,則需要給該用戶配置manager-script權限


4、我使用到了網頁和maven插件的熱部署,配置如下

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


5、重啓tomcat,然後訪問網頁tomcat的後臺


6、網頁熱部署



7、使用maven熱部署,配置如下:

<build>
		<plugins>
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<configuration>
					<path>/</path>
					<!-- 這裏的ip和端口號是訪問tomcat首頁的端口 -->
					<url>http://192.168.25.135:8080/manager/text</url>
					<username>tomcat</username>
					<password>tomcat</password>
				</configuration>
			</plugin>
		</plugins>
	</build>

8、執行maven命令 (clean tomcat7:redeploy -DskipTests)這樣就可以吧項目部署到對應的服務器上了


9、通過瀏覽器訪問到對應的項目路徑,注意:再發布的時候,項目中的localhost路徑需要更改爲對應的服務器路徑




發佈了48 篇原創文章 · 獲贊 10 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章