Use the jrebel plug-in for hot loading

Source: Internet
Author: User

When you use eclipse to develop a web application, whenever you modify a JSP or Java file, you do not need to redeploy and start the web server, then refresh the page to see the modified effect, which will reduce our development efficiency. The jrebel plug-in introduced here can implement the function of hot loading class files, that is, after we modify a Java file, JSP file, and configuration file in eclipse, you no longer need to redeploy and restart the web server, but you only need to refresh the page to see the modified results.

Here we will clarify two concepts: Hot deployment and hot loading:

Hot deployment:The entire project is deployed or redeployed when the container status is running. in this case, the entire memory is usually cleared and reloaded. simply put, tomcat or other Web servers will help us reload the project. this method may cause sessin loss.

Hot loading:It is the container state that re-loads and changes the compiled class when running. In this case, the memory will not be cleared, and sessin will not be lost, but it will easily cause memory overflow or the method cannot be found. Because the memory cannot be changed to an image, changing the structure and model of the class will lead to exceptions and there will be no problems in the existing variables and methods. This mode is suitable for use in the development and debugging process, so that the entire project is not loaded, but also saves the time for repeated project start-up.

In addition, the debug mode supports hot loading for ease of use. -- Idea Tomcat web development SSH development and modification class does not restart hot deployment hot loading.

 

Download jrebel

Official: http://www.zeroturnaround.com/jrebel/ (currently official version has been rejected. Zip compressed version download, only provide Eclipse plug-in Version Download)

Jrebel is not an open-source project. Therefore, you can only get the trial permission for 30 days after the download. However, because the Chinese people are too powerful, you can download the cracked version directly.

Cracked version: http://download.csdn.net/download/sbfivwsll/4166691 (4.6 cracked version)

The cracked version downloads a jar and copies it to a directory, such as D:/bin/jrebel. jar (if the downloaded jar is jrebel-x.x.jar, You need to rename it to jrebel. jar)

 

 Configure your ide

Take eclipse as an example. Find the configuration items of the Tomcat runtime environment in eclipse.

Window-preferences-Tomcat-JVM settings

Add in append to JVM Parameters

-Noverify-javaagent: D:/bin/jrebel. Jar
-Drebel. dirs = D: \ workspace \ PRS-framework-integration-test \ target \ Classes
-Drebel. spring_plugin = true
-Drebel. struts2-plugin = true

Note:

The first section (-noverify-javaagent: D:/bin/jrebel. Jar) must be added

The second paragraph is used to specify the directory to be monitored, in myeclipse this value is: Development Project path \ webroot \ WEB-INF \ Classes, test in eclipse this basic can not be added

The fourth section is used to enable struts2 support and decide whether to add it based on the project framework. (Note that the middle section is-not-do not make your own opinions)

In addition, you need to set reloadable = "false" in your Tomcat server. XML to false.

 

For a Maven project, you can add jrebel plug-in support to Pom. xml. This plug-in can automatically help you specify the directory to be monitored. The configuration is as follows:

<Plugin>

<Groupid> org. zeroturnaround </groupid>

<Artifactid> javarebel-Maven-plugin </artifactid>

<Version> 1.0.5 </version>

<Executions>

<Execution>

<ID> Generate-rebel-XML </ID>

<Phase> process-resources </phase>

<Goals>

<Goal> Generate </goal>

</Goals>

</Execution>

</Executions>

</Plugin>

Restart eclipse and start Tomcat testing. It's amazing !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.