maven 實(shí)現(xiàn)tomcat的遠(yuǎn)程部署
系統(tǒng)
2216 0
要將windows環(huán)境下開發(fā)的java項(xiàng)目部署到linux服務(wù)器上,用maven來做是很方便的。具體的步驟如下:
linux服務(wù)器上的tomcat配置有管理權(quán)限的用戶:conf\tomcat-users.xml
-
<?xml?version=
'1.0'
?encoding=
'utf-8'
?> ??
-
<tomcat-users> ??
-
??<role?rolename=
"manager"
/> ??
-
??<user?username=
"marshal"
?password=
"password"
?roles=
"manager"
/> ??
-
</tomcat-users>??
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager"/>
<user username="marshal" password="password" roles="manager"/>
</tomcat-users>
在pom文件的tomcat插件中添加:
-
<plugin> ??
-
????<groupId>org.codehaus.mojo</groupId> ??
-
????<artifactId>tomcat-maven-plugin</artifactId> ??
-
????<configuration> ??
-
????????<url>http:
??
-
????????<server>myserver</server> ??
-
????????<path>/mycontext</path> ??
-
????</configuration> ??
-
</plugin>??
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://localhost:8080/manager</url>
<server>myserver</server>
<path>/mycontext</path>
</configuration>
</plugin>
在.m2/settings.xml文件中增加:
-
<settings?xmlns=
"http://maven.apache.org/POM/4.0.0"
??
-
????????xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
??
-
????????xsi:schemaLocation="http:
??
-
http:
??
-
????????<servers> ??
-
????????????????<server> ??
-
????????????????????????<id>myserver</id> ??
-
????????????????????????<username>marshal</username> ??
-
????????????????????????<password>password</password> ??
-
????????????????</server> ??
-
????????</servers> ??
-
</settings>??
<settings xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>myserver</id>
<username>marshal</username>
<password>password</password>
</server>
</servers>
</settings>
相關(guān)命令
運(yùn)行打包部署:
mvn tomcat:deploy
撤銷部署:
mvn tomcat:undeploy
啟動(dòng)web應(yīng)用:
mvn tomcat:start
停止web應(yīng)用:
mvn tomcat:stop
重新部署:
mvn tomcat:redeploy
部署展開的文件:
-
mvn?war:exploded?tomcat:exploded??
mvn war:exploded tomcat:exploded
原文鏈接地址是
https://dev.easymorse.com/trac/tutorials/wiki/Maven/GetStart
maven 實(shí)現(xiàn)tomcat的遠(yuǎn)程部署
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061
微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元