1、轉換成maven工程java
下載源碼apache-tomcat-8.5.5-src.zip,並解壓到目錄:E:\codeSource\apache-tomcat-8.5.5-src,在該目錄下建pom.xml文件,文件內容以下:web
<?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>Tomcat8.0</artifactId> <name>Tomcat8.0</name> <version>8.0</version> <build> <finalName>Tomcat8.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.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> <version>3.4</version> </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.5.1</version> </dependency> </dependencies> </project>
2、導入IDEAapache
打開intellij IDEA,在彈出的對話框選擇Import Project
,選E:\codeSource\apache-tomcat-8.5.5-src\pox.xml。一路點擊Next
便可。導入後源碼結構以下:tomcat
導入後檢查下idea使用的jdk版本是不是1.8.0_45。app
3、啓動tomcateclipse
一、E:\codeSource下新建目錄catalina-homewebapp
二、下載apache-tomcat-8.5.5.zip,解壓:maven
將bin,conf,lib,logs,temp,webapps,work目錄拷貝到E:\codeSource\catalina-home目錄下。ide
三、配置啓動項ui
四、編譯tomcat
五、編譯成功後點擊:idea右上角的來啓動tomcat。
啓動成功後咱們訪問http://localhost:8080:
至此tomcat8的源碼環境搭建完成,接下來就能夠盡情的享受源碼了。
4、驗證:
tomcat啓動類:
org.apache.catalina.startup.Bootstrap
在該類的main方法中加入一行
System.out.println("start tomcat 8.5.5");
再來啓動tomcat能夠看到:
看到了嗎?如今你輕輕鬆鬆就能修改源碼了。