IntelliJ IDEA使用maven實(shí)現(xiàn)tomcat的熱部署
在tomcat的conf目錄 tomcat-users.xml配置以下內(nèi)容(<tomcat-users>標(biāo)簽內(nèi)</tomcat-users>),用于部署:
<role rolename="manager"/> <role rolename="manager-gui"/> <role rolename="admin"/> <role rolename="admin-gui"/> <role rolename="manager-script"/> <user username="tomcat" password="tomcat" roles="admin-gui,admin,manager-gui,manager,manager-script"/
啟動(dòng)tomcat,訪問(wèn) http:ip:8080/manager 驗(yàn)證tomcat用戶是否配置成功

在maven工程的pom.xml中配置插件
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<port>8080</port>
<path>/mvc</path>
<url>http://192.168.43.128:8080/manager/text</url>
<username>tomcat</username>
<password>tomcat</password>
</configuration>
</plugin>
運(yùn)行配置
點(diǎn)擊Run-->Edit Configurations
點(diǎn)擊+號(hào),選擇Maven ,
輸入信息
Name 給運(yùn)行配置取的名稱
Working directory(工程目錄)
Command line 命令 tomcat7:deploy 或 tomcat7:redeploy

點(diǎn)擊確定,保存。
在Run菜單下找到剛做好的配置,運(yùn)行
[INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for org.jstudioframework:jstudio-mvc:war:1.0-SNAPSHOT [WARNING] 'build.plugins.plugin.version' for org.apache.tomcat.maven:tomcat7-maven-plugin is missing. @ line 91, column 21 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building jstudio-mvc 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> tomcat7-maven-plugin:2.2:redeploy (default-cli) @ jstudio-mvc >>> [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ jstudio-mvc --- [debug] execute contextualize [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 5 resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ jstudio-mvc --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ jstudio-mvc --- [debug] execute contextualize [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory E:\JstudioProject1\JstudioMvc\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ jstudio-mvc --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.14:test (default-test) @ jstudio-mvc --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-war-plugin:2.1.1:war (default-war) @ jstudio-mvc --- [INFO] Packaging webapp [INFO] Assembling webapp [jstudio-mvc] in [E:\JstudioProject1\JstudioMvc\target\jstudio-mvc-1.0-SNAPSHOT] [INFO] Processing war project [INFO] Copying webapp resources [E:\JstudioProject1\JstudioMvc\src\main\webapp] [INFO] Webapp assembled in [177 msecs] [INFO] Building war: E:\JstudioProject1\JstudioMvc\target\jstudio-mvc-1.0-SNAPSHOT.war [WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored (webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true') [INFO] [INFO] <<< tomcat7-maven-plugin:2.2:redeploy (default-cli) @ jstudio-mvc <<< [INFO] [INFO] --- tomcat7-maven-plugin:2.2:redeploy (default-cli) @ jstudio-mvc --- [INFO] Deploying war to http://192.168.43.128:8080/mvc SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Uploading: http://192.168.43.128:8080/manager/text/deploy?path=%2Fmvc&update=true Uploaded: http://192.168.43.128:8080/manager/text/deploy?path=%2Fmvc&update=true (7445 KB at 7083.3 KB/sec) [INFO] tomcatManager status code:200, ReasonPhrase:OK [INFO] OK - Deployed application at context path /mvc [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 14.720s [INFO] Finished at: Sun Jul 23 19:35:01 CST 2017 [INFO] Final Memory: 15M/322M [INFO] ------------------------------------------------------------------------ Process finished with exit code 0
發(fā)布成功。
在tomcat的manager可以看到新發(fā)布的應(yīng)用。

方法2:

這幾個(gè)標(biāo)紅的菜單都能遠(yuǎn)程發(fā)布
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
一文詳解Java中的可變對(duì)象(Mutable)與不可變對(duì)象(Immutable)
如何在 Java 中創(chuàng)建不可變對(duì)象?我以前以為所有對(duì)象都是不可變的,因?yàn)槿绻愀淖円粋€(gè) String 實(shí)例的內(nèi)容,它總是會(huì)創(chuàng)建一個(gè)新的 String 對(duì)象并指向該對(duì)象,在本文中,我不僅將分享在 Java 中Immutable的步驟,還將討論可變對(duì)象與不可變對(duì)象及其優(yōu)缺點(diǎn)2023-11-11
Swagger-boostrap-ui如何配置用戶名密碼訪問(wèn)
這篇文章主要介紹了Swagger-boostrap-ui如何配置用戶名密碼訪問(wèn),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-05-05
Spring Cloud Feign實(shí)現(xiàn)動(dòng)態(tài)URL
本文主要介紹了Spring Cloud Feign實(shí)現(xiàn)動(dòng)態(tài)URL,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-02-02
java獲取redis日志信息與動(dòng)態(tài)監(jiān)控信息的方法
這篇文章主要給大家介紹了關(guān)于java如何獲取redis日志信息與動(dòng)態(tài)監(jiān)控信息的方法,文中介紹的非常詳細(xì),對(duì)大家具有一定的參考價(jià)值,需要的朋友們下面來(lái)一起看看吧。2017-04-04
Java的Synchronized關(guān)鍵字學(xué)習(xí)指南(全面 & 詳細(xì))
這篇文章主要給大家介紹了關(guān)于Java的Synchronized關(guān)鍵字的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03
java文件/圖片的上傳與下載以及MultipartFile詳解
文章介紹了MultipartFile類的使用,包括獲取文件名、文件類型、文件大小等方法,以及如何處理多文件上傳和文件大小限制,同時(shí)提供了文件上傳和下載的示例代碼2025-02-02
SpringBoot條件注解核心作用與使用場(chǎng)景詳解
Spring?Boot的條件注解為開(kāi)發(fā)者提供了強(qiáng)大的動(dòng)態(tài)配置能力,理解其原理和適用場(chǎng)景是構(gòu)建靈活、可擴(kuò)展應(yīng)用的關(guān)鍵,本文將系統(tǒng)梳理所有常用的條件注解,結(jié)合代碼示例說(shuō)明其作用與使用場(chǎng)景,感興趣的朋友一起看看吧2025-04-04
JAVA統(tǒng)計(jì)字符串中某個(gè)字符出現(xiàn)次數(shù)的方法實(shí)現(xiàn)
本文主要介紹了JAVA統(tǒng)計(jì)字符串中某個(gè)字符出現(xiàn)次數(shù)的方法實(shí)現(xiàn),可以循環(huán)使用String的charAt(int index)函數(shù),具有一定的參考價(jià)值,感興趣的可以了解一下2023-11-11

