生活随笔
收集整理的這篇文章主要介紹了
Tomcat源码解析一:下载源码与导入eclipse
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
自從寫web程序以來,web程序是如何在Tomcat中運行的一直困惑著我,不知道底層的運行機制是無法真正理解web的,所以就開始研究Tomcat源碼,Tomcat是一個輕量級的java服務(wù)器,再結(jié)合《How Tomcat works》和網(wǎng)上大牛博客之后,也算知道了內(nèi)部的運行架構(gòu)。
? ? 首先去官網(wǎng)下載Tomcat源碼,我下載的是apache-tomcat-7.0.63-src(在這里下載),因為源碼使用ant和maven管理的,所以要用ant或者maven編譯為eclipse工程。ant方法編譯時有好多錯誤,又麻煩,所以這里介紹用maven將其編譯。
? ??首先將下載的apache-tomcat-7.0.50-src.tar.gz解壓到tomcat目錄中,然后在tomcat目錄中創(chuàng)建一個pom.xml文件,內(nèi)容如下:
[html]?view plaincopy
<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
目錄下創(chuàng)建一個
pom.xml
文件,內(nèi)容如下:
[html]?view plaincopy
<?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
目錄下執(zhí)行
mvn eclipse:eclipse
生成Eclipse工程,導(dǎo)入進去即可.
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎
總結(jié)
以上是生活随笔為你收集整理的Tomcat源码解析一:下载源码与导入eclipse的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。