Tomcat源码构建
前三篇文章完成了一个类tomcat功能的Mini-Tomcat,本文下载源码进行构建便于后续探讨Tomcat自身调优。
1、下载源码(版本10.1.19)。
2、在apache-tomcat-10.1.19-src下新建pom.xml文件,添加编译所需依赖(不同版本依赖有区别,具体情况具体分析解决)。Tomcat10.1.19版本添加的依赖如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>apache-tomcat-10.1.19-src</artifactId>
<name>Tomcat10.1.19</name>
<version>10.1.19</version>
<build>
<finalName>Tomcat10.1.19</finalName>
<sourceDirectory>java</sourceDirectory>
<resources>
<resource>
<directory>java</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>5.2.0</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>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>javax.xml.soap-api</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>jakartaee-migration</artifactId>
<version>1.0.8</version>
</dependency>
<dependency>
<groupId>biz.aQute.bnd</groupId>
<artifactId>biz.aQute.bndlib</artifactId>
<version>7.0.0</version>
</dependency>
</dependencies>
</project>
3、将源码⼯程导⼊到 IDEA中,并给 tomcat 的源码程序启动类 Bootstrap 配置 VM 参数,因为 tomcat 源码运⾏也需要加载配置⽂ 件等:
catalina.home=D:\Ideaworkspace\apache-tomcat-10.1.19-src\source;
catalina.base=D:\Ideaworkspace\apache-tomcat-10.1.19-src\source;
java.util.logging.manager=org.apache.juli.ClassLoaderLogManager;
java.util.logging.config.file=D:\Ideaworkspace\apache-tomcat-10.1.19-src\source\conf\logging.properties
4、测试启动程序,成功: