Import Tomcat source code into eclipse

Environment: windows 7, jdk 1.8, tomcat8, ant, eclispe

1. Download the tomcat source code: https://archive.apache.org/dist/tomcat/
write picture description here
You can download the tomcat src according to the version you need, I downloaded 8.5.29 here
write picture description here

2. Modify the file build.propertises.default under the source package to build.propertises, and modify the base.path path in the file to the local path.
write picture description here

write picture description here

3. cmd enters apache-tomcat-8.5.29-src and executes: ant download
4. Execute ant. (In the process of executing ant, there may be a connection timeout, just execute ant again)
write picture description here

5. After the ant is successful, open eclipse, create a java project, and name it tomcat8. After the project is created, right-click the tomcat8 project –> import… –> select File system
write picture description here
to select the java directory, and check the option in the figure below. After
write picture description here
importing Import test the same as importing java. After completion, mark the java and test directories as source folders, right-click and select Folder->Build Path->Use as Source Folder. Both code directories got errors after being marked as source folder. This is because of missing dependency packages.
The required jar package is shown in the following figure:
write picture description here

  • ant.jar: in the ant directory you installed: ANT_HOME/lib.
  • jaxrpc.jar: in the /plugin/javax.xml.rpc_xxx (version number)/lib/ directory under eclipse.
  • org.eclipse.jdt.core_3.12.3.v20170228-1205.jar: in the plugin directory of eclipse. Different Eclipse versions may have different names.
  • wsdl4j-1.5.1.jar and junit packages can be downloaded from the Internet.
    After the import, there are some java in the test that will report an error, which does not affect.
    write picture description here
    At this time, start org.apache.catalina.startup.Bootstrap, and the error cannot be loaded to server.xml.
    write picture description here
    At this time, you need to copy the conf and lib folders under apache-tomcat-8.5.29-src\output\build to tomcat8
    write picture description here
    under Refresh the project in eclipse, re-run Bootstrap, success.

test:

Copy the ROOT directory under apache-tomcat-8.5.29-src\webapps to the webapps under the tomcat8 project, run Bootstrap, and visit http://127.0.0.1:8080/ in the browser , you can see the following interface .
write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325564383&siteId=291194637