---
title: "取消tomcat自动重新加载，采用JRebel实时加载部分更改类"
author: "pipe"
date: "2010-05-14T14:14:30Z"
tags: []
categories: ["企业架构"]
slug: "tomcat-jrebel"
draft: false
lastmod: "2010-07-07T14:09:53Z"
id: 666406
url: "https://pipe.iteye.com/blog/666406"
---

在java web项目中，经常需要在web服务器启动之后再更改java类。这样会导致服务器自动重新加载更改的java类，自动重新加载的时间需要等待，然后还导致session失效，需要重新登录。
现在 我们考虑用JRebel来实时加载部分更改类，这样就无需服务器重新加载了，无需等待，session也不会消失。即时更改，即时生效。
步骤如下：
1.下载javaRebel
http://www.zeroturnaround.com/jrebel/current/
我选择的是jrebel-3.0.1-setup.zip,解压之后在控制台执行java -jar jrebel-setup.jar，进行安装。
![](http://dl.iteye.com/upload/attachment/249564/2cccb9b8-0e3a-3251-9858-499d430308b1.jpg)


2.采用eclipse3.3以上版本，我目前用的是eclipse3.5
javaRebel的eclipse在线更新地址:
http://www.zeroturnaround.com/update-site/

![](http://dl.iteye.com/upload/attachment/249566/b2fccd38-7e8c-3b5e-a7ca-7167c91c6471.jpg)


3.
window-preferences-JRebel 指定JRebel的安装目录中的jar，如：E:\JRebel\jrebel.jar

![](http://dl.iteye.com/upload/attachment/249568/5120052b-07c5-32ab-a5e4-5c3d093d0c79.jpg)



4.配置tomcat
Run-Run configurations

在JRebel标签上 勾上Enable JRebel agent.

![](http://dl.iteye.com/upload/attachment/249572/7e7bf1c0-5a07-3f2f-895f-e7785fe09e9e.jpg)


5.在项目数据源连接配置中（我的是在META-INF\context.xml中）
<Context antiResourceLocking="false" reloadable="false">
设置reloadable="false"
或者在tomcat的server.xml的context里面加上reloadable="false"
这是取消tomcat的自动重载.

我的eclipse版本为:eclipse-jee-galileo-SR2-win32.zip 这是eclipse3.5 自带wtp插件



下面上传一个破解的jrebel,也是在网上找的.