IntelliJ IDEA使用maven实现tomcat的热部署

 更新时间:2018年07月02日 10:58:02   作者:猪脚踏浪  
这篇文章主要介绍了IntelliJ IDEA使用maven实现tomcat的热部署,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

在tomcat的conf目录 tomcat-users.xml配置以下内容(<tomcat-users>标签内</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"/ 

启动tomcat,访问 http:ip:8080/manager 验证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>

运行配置

点击Run-->Edit Configurations

点击+号,选择Maven ,

输入信息

Name 给运行配置取的名称

Working directory(工程目录)

Command line 命令 tomcat7:deploy 或 tomcat7:redeploy


点击确定,保存。

在Run菜单下找到刚做好的配置,运行

[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

发布成功。

在tomcat的manager可以看到新发布的应用。


方法2:


这几个标红的菜单都能远程发布

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章

  • 一文详解Java中的可变对象(Mutable)与不可变对象(Immutable)

    一文详解Java中的可变对象(Mutable)与不可变对象(Immutable)

    如何在 Java 中创建不可变对象?我以前以为所有对象都是不可变的,因为如果你改变一个 String 实例的内容,它总是会创建一个新的 String 对象并指向该对象,在本文中,我不仅将分享在 Java 中Immutable的步骤,还将讨论可变对象与不可变对象及其优缺点
    2023-11-11
  • Eureka源码核心类预备知识

    Eureka源码核心类预备知识

    这篇文章主要为大家介绍了Eureka源码核心类预备知识详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2022-10-10
  • Spring配置使用之Bean生命周期详解

    Spring配置使用之Bean生命周期详解

    这篇文章主要介绍了Spring配置使用之Bean生命周期详解,具有一定参考价值,需要的朋友可以了解下。
    2017-10-10
  • Swagger-boostrap-ui如何配置用户名密码访问

    Swagger-boostrap-ui如何配置用户名密码访问

    这篇文章主要介绍了Swagger-boostrap-ui如何配置用户名密码访问,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2023-05-05
  • Spring Cloud Feign实现动态URL

    Spring Cloud Feign实现动态URL

    本文主要介绍了Spring Cloud Feign实现动态URL,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-02-02
  • java获取redis日志信息与动态监控信息的方法

    java获取redis日志信息与动态监控信息的方法

    这篇文章主要给大家介绍了关于java如何获取redis日志信息与动态监控信息的方法,文中介绍的非常详细,对大家具有一定的参考价值,需要的朋友们下面来一起看看吧。
    2017-04-04
  • Java的Synchronized关键字学习指南(全面 & 详细)

    Java的Synchronized关键字学习指南(全面 & 详细)

    这篇文章主要给大家介绍了关于Java的Synchronized关键字的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2021-03-03
  • java文件/图片的上传与下载以及MultipartFile详解

    java文件/图片的上传与下载以及MultipartFile详解

    文章介绍了MultipartFile类的使用,包括获取文件名、文件类型、文件大小等方法,以及如何处理多文件上传和文件大小限制,同时提供了文件上传和下载的示例代码
    2025-02-02
  • SpringBoot条件注解核心作用与使用场景详解

    SpringBoot条件注解核心作用与使用场景详解

    Spring Boot的条件注解为开发者提供了强大的动态配置能力,理解其原理和适用场景是构建灵活、可扩展应用的关键,本文将系统梳理所有常用的条件注解,结合代码示例说明其作用与使用场景,感兴趣的朋友一起看看吧
    2025-04-04
  • JAVA统计字符串中某个字符出现次数的方法实现

    JAVA统计字符串中某个字符出现次数的方法实现

    本文主要介绍了JAVA统计字符串中某个字符出现次数的方法实现,可以循环使用String的charAt(int index)函数,具有一定的参考价值,感兴趣的可以了解一下
    2023-11-11

最新评论