There are two methods for compiling Java classes without restarting Tomcat: Hot deployment and hot loading.

Source: Internet
Author: User

There are two ways to disable Tomcat restart: Hot deployment and hot loading.
Hot deployment: re-deploy the entire project while the container is running. In such environments, the entire memory is usually cleared and reloaded.
It may cause sessin loss and other environments. Tomcat 6 can be hot deployed, and the conversation is not lost.
Hot loading: it is best to use it during debugging without loading the entire project. The debug standard style supports hot loading. Container condition is re-running
New loaded and converted compiled classes. In this type of environment, the memory will not be cleared, and sessin will not be lost, but it may easily cause memory overflow or cannot be found.
Method. In general, the layout and model of the transformation class will be abnormal, and there will be no problems with the existing variables and methods (Eclipse,
Myeclipse8, JBuilder, intellij idea ...).
The second method is usually used: Hot loading. The settings are as follows!
Add <context Path = "/test" to the host settings in server. XML in the conf file of Tomcat"
Docbase = "D: \ develop \ test"
DEBUG = "0" privileged = "true" reloadable = "true"/>
Reloadable = "true "! Most important
It has many attributes, meaning as follows:
1> path: Specifies the URL for the Web application to be imported;
2> docbase: Specifies the file path of the Web application, which can be an absolute path or an appbase attribute relative to Point to the relative path of Tomcat webapps. If the web application is a war file, specify the path of the war file.
3> classname: Specifies the name of the Java class used to make the fact context component. This Java class must become the fact org. Apache. Catalina. Context
Api. The default value of this attribute is org. Apache. Catalina. standardcontext.
4> reloadable: If this property is set to true, the Tomcat server will monitor-
INF/lib directory under the class file changes, as well as monitoring web application WEB-INF/Web. xml file changes. If the detected class
When the file or web. xml file is updated, the server automatically loads the web application. The default value of this attribute is false.
In the trial phase, set reloadable to true to facilitate web application debugging. Set reloadable
False, which can reduce the Running Load of Tomcat and improve the running performance of Tomcat.
5> cachingallowed: if it is true, it indicates that static resource caching is allowed. Caching can improve the efficiency of waiting for static resources.
Tomcat caches some static resources (such as HTML files, image files, and audible files) that are frequently favored by clients.
When waiting for static resources, Tomcat only needs to read the relevant data directly from the cache and does not need to read files from the file system repeatedly. This genus
The default value is true.
6> cachemaxsize: sets the maximum cache capacity of static resources, in K units. If the attribute is 100, the value is 100 kb. The default value is kb.
It is 10240 (10 m ).
7> workdir: Specifies the work directory of the Web application. Tomcat stores the exam-taking articles related to this Web application in this directory during running.
8> uppackwar: If this parameter is set to true, the war file of the Web application will be opened as an open directory layout before running. If it is set
If this parameter is set to false, the war file is directly run. The default value of this attribute is true.
Thank you for your attention when using atat6.0. When you use my methods to set tomcat, do not panic when your myeclipse reports the following error. This is correct and I will explain it.
Console error:
Warning: [setpropertiesrule] {server/service/engine/host/context} setting property 'debug' to '0' did not find a matching property. this is because you are using tomcat6.0, because it is a fact that the DEBUG = "0" attribute is used in other ways during the process, so this attribute cannot be used again. You just need to remove it and it will be okay.
That is to say, remove DEBUG = "0" and everything is OK.

========================================================== ====================================
Another method is to use a third-party tool.

Http://www.zeroturnaround.com/jrebel/

1. decompress the package

2. execute Java-jar jrebel-setup.jar

3. An installation interface will pop up (easy to understand)

4. Configure in myeclipse, find the configuration page of the server (such as Tomcat), and add the following parameters in the optional Java VM arguments input box on the JDK configuration page of Tomcat:

-Noverify-javaagent: D: \ Dev \ jrebel. jar-drebel. dirs = D: \ Dev \ apache-Tomcat-6.0.20 \ webapps \ NMR

The first path is the absolute path of the jar package, and the second address is the directory in which the class is to be changed without restarting the service.

If the optional Java VM arguments input box contains other parameters, separate them with spaces.

5. Release the project and you will be able to see the effect on the console.

Class can be changed without restarting tomcat.

Currently, all popular servers are supported. For more information, see the official website.

The downloaded compressed package is named jrebel-setup.zip (7.8 MB)
See: http://japankn.javaeye.com/blog/577931

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.