1. Get the source code
Mode one: from the official website http://tomcat.apache.org/download-70.cgi direct download, the official website provides binary and source code two download method, to study the tomcat source code, select the bottom source Way to download
Method Two: Use SVN to get the source code, first install SVN, then create a new directory TOMCAT7, and then in the directory with SVN execute the following command
SVN Co http://svn.apache.org/repos/asf/tomcat/tc7.0.x/tags/tomcat_7_0_35/./download Source
2. Import the source code into eclipse
Download the source code, please refer to the Tomcat official website http://tomcat.apache.org/tomcat-7.0-doc/building.html the detailed source code import step, this is the best document.
Tomcat's source code is created and managed using Ant. After you install Ant and then execute Ant ide-eclipse, the command executes successfully and is produced in the TOMCAT7 directory. Project and. Classpath two files, which became Eclipse Engineering. This allows you to import the Tomcat source into eclipse (via general--"exisiting Projects into Workspace choose ant compiled Tomcat source) Tomcat source import eclipse In the future may encounter JDK version or JAR package (JUnit and other jar package) issues (in accordance with the official website import, usually not missing jar package), self-resolved JDK version conflict after the import successful if there is a problem, you can remove the examples folder
3. Start TomcatRun Tomcat: Find the Bootstrap class under Tomcat's startup main class Org.apache.catalina.startup package, right-click "Run as", "Run Configurations", In the arguments window, make the following settings:
Write in program arguments: Start
Write in VM arguments:-dcatalina.home= "F:\project\tomcat\apache-tomcat-6.0.18-src\output\build". As shown in the following:
Then run, you can see that Tomcat started successfully, as shown in:
(5) Stop Tomcat: As in the previous step, write in program arguments: Stop, click Run. To stop Tomcat. When the Tomcat source code is successfully imported, it is possible to debug the tomcat operation mechanism by debugging step-by-step.
Tomcat Source Import Eclipse