Web application configuration in eclipse Environment

Source: Internet
Author: User

Note: article from: http://hi.baidu.com/sxzhengmm/item/d364080611aa52fba0103434

 

There are probably two developers who use eclipse to develop Web applications. One is directly using eclipse Jee, and the other is using myeclipse. The two have their own advantages and disadvantages. I think myeclipse's big integration trial development may save a lot of basic things for beginners to get started easily. For those above the entry level, I think the basic eclipse is a better choice. On the one hand, myeclipse's add XXX capabilities, no matter how many files are added to the entire library, is a pollution to the project. On the other hand, many hidden things are not conducive to the individual's learning about the specific implementation.

Let's get down to the truth and talk about Web application debugging in these two environments. This was a simple task, but the IDE did not provide good guidance in the case of a few great roads to Rome. As a result, many people use relatively inefficient methods. Let's look at my comparison:

1. Eclipse Jee version, which can be done without plug-ins

Without myeclipse, many developers like to install a lomboz plug-in to manage Tomcat and perform development, deployment, and testing after reading the online nonsense articles. But, in fact, if you just debug a web application, you don't need to install these Wuzhi stuff, you can do it directly.

Choose WINDOW> show view on the menu to bring out the servers panel. This is the application server management module that eclipse originally had. Right-click the Panel and choose new> server. In this case, you can select the appserver type you are using. If the list does not contain your appserver, you can click the download additional server adapters to search for the download. If you are using tomcat, select the corresponding version of Tomcat under the Apache directory, and select the Tomcat directory you have installed in the subsequent steps, you can configure a Tomcat server in your eclipse environment.

After configuring the server, you will find that there is a project called servers in the project browsing panel on the left, which is actually the configuration of your server. Many developers use tomcat to modify the ctor node in server. xml and add configurations such as uriencoding. Note that you need to select the corresponding server in the servers panel, right-click and select publish to make the modification take effect. In fact, the configuration file you modified is copied to the actual working directory such as $ workspace/. Metadata/.../tmp0.

After Tomcat is configured, how can I start running my project. Double-click the server you created in the servers panel and two tabs are displayed. Select the modules tab. Then, use the second button on the right to add your web application. Document base writes the absolute path of your project's web directory, saves it, and starts the server in debug mode. Your project runs and can be debugged. If you modify a file, you do not need to use garbage such as lomboz to direct you to deploy or other things. In some cases, you have modified the class. After the project is re-compiled, the server will pop up a dialog box that cannot continue debugging. At this time, you need to restart the server.

We do not recommend that you add web modules. This item often changes the project file but does not take effect. It is also not recommended to right-click the add or remove projects on the server. The same problem.

Finally, let's talk about the deploy function provided by plug-ins such as lomboz. I don't think this is a feature used in the development process. The actual process is to copy the files in your project to the webapps directory of Tomcat you configured. It often does not recognize which files have been modified. So you didn't modify something. To take effect, deploy is required, and this deploy copies the entire web directory, so you should wait. Slow to death.

2. myeclipse

First, in general, I think this is a spam. However, it is no longer harsh for beginners to save a lot of trouble.

This tool provides its own server management module and covers eclipse's own module. Adding an application to a server is equally silly as lomboz. Finally, you modified things during the development process and implemented a deploy function for you to click. It copied all the files to the Tomcat webapps directory. Silly X is not terrible. What's terrible is that you have cut the function of adding the external web module to the server provided by ECLIPSE, leaving you nowhere to go.

However, there are other ways to ignore this silly x deploy function. After configuring tomcat in the configuration of myeclips, the Tomcat is actually started using the configuration under the Tomcat directory you have installed (this is different from eclipse, eclipse implements a set of configurations and stores them in workspace /. in metadata ). Therefore, we can create an XML file in the conf/Catalina/localhost directory of Tomcat, and write the following content:

<Contextdocbase = "E: \ workspace \ Java \ projecta/Web" Path = "/" reloadable = "false"/>

It actually tells tomcat to load a project at startup. In this way, you can start the server in debug mode in eclipse to debug it. It also removes the hassle of deploy and so on. modifying files usually takes effect directly.

 

Note: Two problems may occur:
1) The path cannot be found. This is because in eclipse with Jee, it does not create a default homepage (index. JSP), so you have to create a home page under the webcontent directory by yourself. There are many options to create a home page here. XML. You can set a lot of access paths for the home page files of the project. You can just create one according to the rules here;

2) You may want to directly enter http: // localhost: 8080 to view the homepage of Tomcat's cute kitten, but you cannot find the file. Here, Step 1: right-click the server in servers, and delete all projects in add or remove projects, that is, clear the project, and click OK. Step 2: double-click the server, in this case, a tomcat configuration page is displayed, server location is found on the page, and deploy path is found in server location. (Note: all projects must be cleared. This is configurable, otherwise it will be gray), and then select the webapps under the tomcat installation directory as the deploy
Path, save the settings (CTRL + S, huh, huh); Step 3: restart Tomcat and you can see the cool kitten again.
So far, we can use eclipse Jee for web development just like using myeclipse.

Related Article

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.