菜鸟教程之工具使用——借助JRebel使Tomcat支持热部署


JRebel是一个J2EE热部署的工具。使用它可以减少浪费8-18%的开发时间在项目的构建和部署上。虽然Java也提供了HotSpot的JVM,但是如果你修改的类中有方法名称变动的话,HotSpot就无能为力了,必须要重要启动应用服务器。JRebel则可以动态监视class文件及配置文件,如果有文件更新,被调用时就会被JRebel重新加载,达到热部署的目的。

JRebel不仅可以在开发阶段实现热部署来提高开发效率,在项目部署投入使用以后也支持动态的加载,从而可以帮助程序完成一些特殊的功能,让程序变得更加灵活。下面我们一起来看看它到底怎么用吧。

开发阶段:

JRebel支持Eclipse、MyEclipse、IntelliJ、NetBeans等众多IDE,我们以Eclipse为例,在Eclipse中想要使用JRebel,我们需要安装一个插件,可以在Eclipse Marketplace中搜索安装,也可以使用install new software通过URL来安装。url为:http://www.zeroturnaround.com/update-site/。具体怎么安装插件就不赘述了,不知道的自己百度一下。

安装完插件,Eclipse重启,然后按照下面的步骤配置即可:

Window——>Preferences——>JRebel


点击“JRebel Config Center”按图勾选,并添加自己下载的JRebel的jar包以及lic文件。


最后配置Tomcat的属性,按下图勾选相应属性即可。


部署后的动态加载:

配置很简单,只需要设置两个环境变量即可,

环境变量名:
JAVA_OPTS
环境变量值:
-javaagent:%REBEL_HOME%\jrebel.jar -Drebel.hibernate_plugin=true -Drebel.spring_plugin=true -Drebel.struts2_plugin=true

环境变量名:
REBEL_HOME
环境变量值:
D:\jrebel-5.6.3-crack(这个路径就是你JRebel的解压目录)




接下来运行Tomcat的startu.bat,在开头会出现以下信息:

2014-10-08 21:22:08 JRebel:
2014-10-08 21:22:08 JRebel: #############################################################
2014-10-08 21:22:08 JRebel:
2014-10-08 21:22:08 JRebel:  JRebel 5.6.3 (201409050929)
2014-10-08 21:22:08 JRebel:  (c) Copyright ZeroTurnaround OU, Estonia, Tartu.
2014-10-08 21:22:08 JRebel:
2014-10-08 21:22:08 JRebel:  Over the last 2 days JRebel prevented
2014-10-08 21:22:08 JRebel:  at least 43 redeploys/restarts saving you about 1.7 hours.
2014-10-08 21:22:08 JRebel:
2014-10-08 21:22:08 JRebel:  This product is licensed to anonymous-user
2014-10-08 21:22:08 JRebel:  for unlimited number of developer seats on site.
2014-10-08 21:22:08 JRebel:  ####### Cracked by anonymous-user, For FUN! Unlimited! Enjoy! ######
2014-10-08 21:22:08 JRebel:
2014-10-08 21:22:08 JRebel:
2014-10-08 21:22:08 JRebel:
2014-10-08 21:22:08 JRebel:  The following plugins are disabled at the moment:
2014-10-08 21:22:08 JRebel:  * Axis2 WAS plugin (set -Drebel.axis2_was_plugin=true to enable)
2014-10-08 21:22:08 JRebel:
2014-10-08 21:22:08 JRebel: #############################################################
2014-10-08 21:22:08 JRebel:


ok这样表示已经配置成功了,如果环境变量不起作用,可以在Tomcat的startup.bat的开头加入如下代码:

@echo off
set JAVA_OPTS=-javaagent:[path/to/]jrebel.jar %JAVA_OPTS%
call "%~dp0\catalina.bat" %*


[path/to/]为你的JRebel解压目录。

好了,这样就都配置好了,快快感受一下吧!

附JRebel破解版下载地址:

jrebel-5.6.3-crack 破解版

 

刘水镜 CSDN认证博客专家 Spring Boot 架构 Java
【欢迎阅读我的最新专栏——《SpringBoot趣味私房课》https://www.imooc.com/read/75】【欢迎加入「开发者」技术交流群:168965372】【群链接:https://jq.qq.com/?_wv=1027&k=Inxd5Aa9】
已标记关键词 清除标记
部署之后启动tomcat报错 严重: Context initialization failed org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.zeroturnaround.com] Offending resource: file [E:\eclipse\workspace\pixivmaven\target\classes\rebel.xml] at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:316) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1424) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1417) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:180) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:144) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:100) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:510) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) at org.springframework.context.support.AbstractRefreshableApplicationContext.__refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:452) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)
©️2020 CSDN 皮肤主题: 猿与汪的秘密 设计师:上身试试 返回首页