标签:
自从写web程序以来,web程序是如何在Tomcat中运行的一直困惑着我,不知道底层的运行机制是无法真正理解web的,所以就开始研究Tomcat源码,Tomcat是一个轻量级的java服务器,再结合《How Tomcat works》和网上大牛博客之后,也算知道了内部的运行架构。
首先去官网下载Tomcat源码,我下载的是apache-tomcat-7.0.63-src(在这里下载),因为源码使用ant和maven管理的,所以要用ant或者maven编译为eclipse工程。ant方法编译时有好多错误,又麻烦,所以这里介绍用maven将其编译。
首先将下载的apache-tomcat-7.0.50-src.tar.gz
解压到tomcat
目录中,然后在tomcat
目录中创建一个pom.xml
文件,内容如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>net.imtiger</groupId> <artifactId>tomcat-study</artifactId> <name>Tomcat 7.0 Study</name> <version>1.0</version> <packaging>pom</packaging> <modules> <module>apache-tomcat-7.0.63-src</module> </modules> </project>然后在apache-tomcat-7.0.63-src目录下创建一个
pom.xml
文件,内容如下:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.apache.tomcat</groupId> <artifactId>Tomcat7.0</artifactId> <name>Tomcat7.0</name> <version>7.0</version> <build> <finalName>Tomcat7.0</finalName> <sourceDirectory>java</sourceDirectory> <testSourceDirectory>test</testSourceDirectory> <resources> <resource> <directory>java</directory> </resource> </resources> <testResources> <testResource> <directory>test</directory> </testResource> </testResources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3</version> <configuration> <encoding>UTF-8</encoding> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.4</version> <scope>test</scope> </dependency> <dependency> <groupId>ant</groupId> <artifactId>ant</artifactId> <version>1.7.0</version> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.6.2</version> </dependency> <dependency> <groupId>javax.xml</groupId> <artifactId>jaxrpc</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>org.eclipse.jdt.core.compiler</groupId> <artifactId>ecj</artifactId> <version>4.2.2</version> </dependency> </dependencies> </project>最后,在
tomcat
目录下执行mvn
eclipse:eclipse
生成Eclipse工程,导入进去即可.版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/jiaomingliang/article/details/47374495