修改代码后,不重启tomcat的小技巧

使用一个jrebel.jar包可以让减少启动tomcat的次数。

1、比如下载的jrebel.jar包,放置在C:\test\jrebel\jrebel.jar下。

2、有了第一步的操作,你此时可以在配置你的tomcat的地方,的最后一项Optional program  arguments 的值为:

     -noverify -javaagent:C:/test/jrebel/jrebel.jar

 

3、在左边的菜单栏中的,进入Tomcat选项中后,为JDK也配同样的优化参数。

 

启动tomcat,此时在tomcat的最前方有:---》 表示安装成功


#############################################################

 JRebel 3.1.2a (201008121555)
   with Enterprise Add-On! (see http://jrebel.com/enterprise)
 (c) Copyright ZeroTurnaround OU, Estonia, Tartu.

 Over the last 1 days JRebel prevented
 at least 15 redeploys/restarts saving you about 0.6 hours.

 You are running JRebel evaluation license.
 You have 30 days until the license expires.

 You will see this notification until you obtain a
 full license for your installation.
                                                         
 Visit www.jrebel.com for instructions on obtaining   
 a full license. If you wish to continue your evaluation 
 please e-mail to support@zeroturnaround.com.            
                                                         
 If you think you should not see this message contact    
 support@zeroturnaround.com or check that you have your  
 license file in the same directory as the JAR file.     

 The following plugins are disabled at the moment:
 * EclipseLink Plugin (set -Drebel.eclipselink_plugin=true to enable)
Reloads EntityManagerFactory when configuration changes
 * Log4j plugin (set -Drebel.log4j-plugin=true to enable)
Reloads full configuration of log4j
 * Stripes plugin 1.0.11 (set -Drebel.stripes_plugin=true to enable)
Adds reloading of Stripes ActionBeans.
 * TopLink Plugin (set -Drebel.toplink_plugin=true to enable)
Reloads EntityManagerFactory when configuration changes
 * TopLink Spring Plugin (set -Drebel.toplink_spring_plugin=true to enable)
Reloads SeesionFactory when configuration changes
 * WebObjects Plugin (set -Drebel.webobjects_plugin=true to enable)
WebObjects JRebel Plugin

#############################################################

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 如果你想在不重启 Tomcat 的情况下更新你的 Java Web 应用的代码,你可以尝试使用"热部署"功能。这个功能允许你在不停止应用服务的情况下更新应用的代码。 要使用 "热部署" 功能,你需要在你的 Tomcat 应用服务器上启用这个功能。具体来说,你需要修改 Tomcat 的 server.xml 文件,在 Host 节点中添加一个属性: <Host appBase="webapps" autoDeploy="true" deployOnStartup="true" name="localhost" unpackWARs="true"> 然后,你就可以通过以下方式来更新你的应用代码: 1. 在你的应用项目目录下运行 mvn package 命令来打包应用。 2. 将打包后的 WAR 文件复制到 Tomcat 的 webapps 目录下。 3. 在浏览器中访问你的应用,Tomcat 会自动部署新的 WAR 文件。 注意:使用 "热部署" 功能可能会影响应用的性能,并且在更新代码时可能会出现错误。因此,在生产环境中使用 "热部署" 功能是不推荐的。 ### 回答2: 在Javaweb开发中,如果希望更新代码而不重启Tomcat服务器,一种常见的方法是使用热部署(Hot Deployment)。 热部署是指在应用程序运行期间,更新修改代码,而无需重启服务器。具体步骤如下: 1. 在Tomcat的conf目录下,找到server.xml文件,在<Host>标签内添加“autoDeploy="true" deployOnStartup="true"”属性。这会开启自动部署功能。 2. 将Javaweb项目源代码编译成class文件。 3. 将class文件复制到Tomcat的webapps目录下对应的项目文件夹中。 4. Tomcat会自动检测到新的class文件,并重新加载对应的类。这样就完成了代码的更新。 需要注意的是,热部署不适用于所有的代码变更。对于部分修改,如web.xml、配置文件或者一些静态资源的修改,仍然需要重启Tomcat服务器才能生效。 此外,还有一些工具可以帮助实现更方便的热部署,如JRebel、DCEVM等。它们能够实时监控代码的变化,并自动重新加载相关的类,无需手动复制文件。 总而言之,热部署是一种方便的方式,可以快速更新代码,提高开发效率。但需要注意的是,热部署可能会引发一些问题,如内存泄漏、类加载冲突等,因此在使用时需要谨慎操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值