1. 获取源代码
方式一:从官网http://tomcat.apache.org/download-70.cgi 直接下载,官网提供了Binary 和 Source Code两种下载方式,要研究tomcat源代码,选择source code 方式下载
方式二:利用svn获取源代码,先安装svn,再新建目录tomcat7, 接着在目录里执行以下命令
svn co http://svn.apache.org/repos/asf/tomcat/tc7.0.x/tags/TOMCAT_7_0_35/ ./
tags目录下有不同版本的tomcat 源码,这里下载的版本是7.0.35
2. 将源码导入eclipse
tomcat的源码是利用ant来创建和管理的。先安装ant,再执行ant
ide-eclipse,该命令执行成功后,会在tomcat7目录下生产.project和.classpath两个文件,即成为eclipse工程
了。这样你就可以将tomcat源码导入eclipse了。
执行ant ide-eclipse时报错:
BUILD FAILED build.xml:2361: The following error occurred while executing this line:
BUILD FAILED build.xml:2449: Compile failed; see the compiler error output for details.
查看编译的错误日志为:
build-tomcat-dbcp:
[copy] Copying 64 files to E:\usr\share\java\tomcat7-deps\dbcp
[move]