Write in front: the blogger is a real combat development after training into the cause of the “hill pig”, nickname from the cartoon “Lion King” in “Peng Peng”, always optimistic, positive attitude towards things around. My technical path from Java full stack engineer all the way to big data development, data mining field, now there are small achievements, I would like to share with you what I have learned in the past, I hope to help you on the way of learning. At the same time, the blogger also wants to build a perfect technical library through this attempt. Any anomalies, errors and matters needing attention related to the technical points of the article will be listed at the end, and everyone is welcome to provide materials in various ways.
- Please criticize any mistakes in the article and revise them in time.
- If you have any questions you would like to discuss or learn, please contact me at [email protected].
- The style of the published article varies from column to column, and all are self-contained. Please correct the deficiencies.
Integration of Tomcat and IDE – Eclipse
Keywords: Tomcat, Eclipse, integrated configuration, project deployment
The article directories
- Integration of Tomcat and IDE – Eclipse
-
- I. Introduction to Tomcat
- Introduction to Eclipse
- 3. Configure Tomcat in Eclipse
-
- 1. Add Tomcat
- 2. Common configurations
- Iv. Project deployment and access
-
- 1. Create a project
- 2. Project deployment
- 3. Project visit
- Five, video direct
I. Introduction to Tomcat
Tomcat is a core project of the Apache Software Foundation’s Jakarta project. Is an open source free Web application server, belongs to lightweight application server, in small and medium-sized systems and concurrent access users are not a lot of occasions is widely used, is the development and debugging JSP program first choice.
For the installation and configuration of Tomcat, see:Tomcat decompression installation – Windows.
Introduction to Eclipse
Eclipse is mainly used for the development of Java interface applications, JavaWeb applications, Android applications, etc. At the same time, because Eclipse has developed a standard set of plug-ins, so through the development of plug-ins can support the software development of other languages and platforms. Tools such as Hbuilder, STS, SAP HANA Studio are also developed based on the Eclipse platform.
For Eclipse installation and configuration, see:Eclipse Installation and Configuration – Windows.
3. Configure Tomcat in Eclipse
In the development of the project, often to carry out code modification, repeated functional debugging. If you use manual packaging and deployment, not only cumbersome but also affect the development efficiency. Adding Tomcat to Eclipse makes it easy to deploy and start a project, and supports hot updates (changes are automatically synchronized when saved).
1. Add Tomcat
- Prerequisites: The version of Tomcat is supported in Eclipse
Make sure you have the Enterprise version of Eclipse installedAnd then switch toJavaEE view.
Switching to this view has two benefits:
- The Servers window will automatically appear
- When developing a JavaWeb project, the right menu is full of common content (such as servlets, etc.)
The following interface is shown after switching:
If not, try the following two solutions:
- Reset JavaEE View (after switching to JavaEE View)
- Manually open the Servers window:
If you don’t have Servers in the View, you can clickThe Other…Then search in it.
Add a new one to ServersServer:
After successfully adding,Project ExplorerandServersThe newly added Tomcat is displayed, indicating success.
2. Common configurations
After the addition is complete, Eclipse will replace the original Tomcat configuration filecopySo, if we want to change the configuration of Tomcat in Eclipse, we must not go to the original Tomcat installation path to change, but in theProject ExplorerModified in Tomcat configuration file in.
Here are a few important deployment-related configurations to explain, which are common problems encountered by those who are using Tomcat for the first time in Eclipse. Double-click the firstServersTomcat, open the configuration interface:
- Server Locations
Server Locations is an important configuration that specifies where the project is deployed. You can see that the default deployment location is to create one in the workspacewtpwebapps“Folder. This can result in several layers of folders to go through when we want to check the deployed project, which has the advantage of being separate from the original Tomcat project. This saves some time because Tomcat starts up by scanning the contents of all project folders.
The second option is to specify the installation directory to Tomcat. Note that the default project deployment directory iswebappsIs different from the original Tomcat deployment directory. So some of you have a question:Why can’t I access the previous home page after starting Tomcat in Eclipse?
This is because the Tomcat home page we see is actually pre-placed in the Webapps folderROOTProject, which is also the project Tomcat accesses by default. So if the ROOT project is not in the folder we specified, the home page will not be accessible, but Tomcat is already up and running.
The third option is to customize the location, which you can set according to your needs. Generally, the author makes modifications based on the second option, changing the deployment location to the same as the original Tomcat deployment path, and removing unwanted built-in projects. The final Settings are as follows:
Press Ctrl + S to save configuration changes. After this setting, you can not only access the Tomcat home page, but also conveniently find your project deployment location. If the original projects under the Webapps are not needed, you can manually delete them.
Note: This configuration can be changed when Tomcat is added for the first time. If you want to change it again after deploying the project, you need to clear all projects and the cache.
- Timeouts
Timeouts is used to set the timeout period for starting and stopping Tomcat. Some projects fail to be started within a specified period because the project is large. Therefore, you are advised to set the timeout period as follows:
Press Ctrl + S to save configuration changes.
Iv. Project deployment and access
After Tomcat is added, right-click to see the operation menu:
You are advised to add and remove items in the stopped state.
1. Create a project
- Create a Dynamic Web Project
- Fill in the project name and check the configuration
- Continue to complete the creation
2. Project deployment
- Creating a Test page
After the project is created, you can create a new page to access the test:
The page reads as follows:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"% > <! DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>MyProject</title> </head> <body> <h1>Hello World! </h1> </body> </html>Copy the code
- Add the project to Tomcat
Tomcat -> Add and Remove…
Select the project to Add -> click the Add button -> Finish
Items appear in the list:
3. Project visit
- Start Tomcat
First startup, security alert selection encounteredAllow access to:
- Project access
Open the browser, enter the URL – > http://localhost:8080/WebProject
The address format is http://host IP address: default port/project name
Five, video direct
Video address: www.bilibili.com/video/BV1UK… , like the little partner must be three times to add attention oh ~
Integration of Tomcat and IDE – Eclipse
Write at the end: the author tries to refine each knowledge point and use portal to mount links for related knowledge points. The article adopts the way of “text + picture + video” to show, which is squeezed time to make, hope to see here can leave a comment to like, slightly show support!