您的位置:首页 > 运维架构 > Tomcat

eclipse导入tomcat源码

2015-05-22 12:09 393 查看
一直在用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 scriptavailable, which will be used to actually perform the build.ANT_HOME=D:\apache-ant-1.8.0CLASSPATH=%ANT_HOME%\lib;PATH=%ANT_HOME%\bin;第二步,下载tomcat依赖包,编译tomcat源码操作之前要对依赖包的存在放路径进行设置,打开
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
否则修改build.xml中查找setproxy, 将if的值改为false <target name="setproxy" depends="proxyflags" if="false">然后开始运行命令
cd E:\apache-tomcat-6.0.39-src
ant download
ant
以上工作准备好后,就进入第三步,导入eclispe
将apache-tomcat-6.0.39-src文件夹下两个文件eclipse.classpath
eclipse.project另存为
.classpath
.project.
Use Windows->Preferences and then Java->Build Path->ClasspathVariables to add two new Classpath variables:
添加两个参数
TOMCAT_LIBS_BASE   值为D:/ant/tomcat_libs_base/
ANT_HOME 值为
D:\apache-ant-1.8.0Use File-> "Existing Projects into Workspace" 选择apache-tomcat-6.0.39-src目录导入即可。导完项目之后,怎么让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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: