一直在用tomcat,想了解一下tocmat的原理,下面给大家展示如何将源码导入eclipse;
版本apache-tomcat-6.0.39
这里官方教程地址 http://tomcat.apache.org/tomcat-6.0-doc/building.html;
我的整个导入流程也是基于官方的教程,毕竟网上的说法太杂乱了。
准备资源:
tomcat6源码:http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.39/src/;
ant1.8.0: http://archive.apache.org/dist/ant/binaries/ ;
第一步,配置好ant的环境变量
Create an ANT_HOME environment variable to point the directory ${ant.home}, and modify the PATH environment variable to include directory "${ant.home}/bin" in its list. This makes the "ant" command line script available, which will be used to actually perform the build.
ANT_HOME=D:\apache-ant-1.8.0
CLASSPATH=%ANT_HOME%\lib;
PATH=%ANT_HOME%\bin;
第二步,下载tomcat依赖包,编译tomcat源码
cd E:\apache-tomcat-6.0.39-src
ant download
ant
操作之前要对依赖包的存在放路径进行设置,
打开E:\apache-tomcat-6.0.39-src路径下的
build.properties.default文件
设置base.path=D:/ant/tomcat_libs_base/
如果你使用的是http代理,那么请在 build.properties.default中添加如下配置
proxy.host=代理IP
proxy.port=代理端口
proxy.use=on
以上工作准备好后,就进入第三步,导入eclispe
Use Windows->Preferences and then Java->Build Path->Classpath
Variables to add two new Classpath variables:
添加两个参数
TOMCAT_LIBS_BASE 值为D:/ant/tomcat_libs_base/
ANT_HOME 值为
D:\apache-ant-1.8.0
然后创建一个新的项目,new >other>java project from existing ant buildfile
导完项目之后,怎么让tomcat跑起来呢?
To run Tomcat without a special IDE plug-in, you can simply use Run->Run... enter "org.apache.catalina.startup.Catalina" as the main class, "start" as program arguments, and "-Dcatalina.home=..." (with the name of your build directory) as VM arguments.
其实很简单,点右键run as > run configurations 选择java application 再点右键 选择 new 出现如下图:
本文出自 “spring研究者” 博客,请务必保留此出处http://springxml.blog.51cto.com/4900689/1653828
原文地址:http://springxml.blog.51cto.com/4900689/1653828