Tomcat源码分析环境搭建

https://gitee.com/yuanyu1997/apache-tomcat-9.0.41-src


1 版本

1.1 jdk版本

C:\Users\baker.yuan>java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)

1.2 tomcat版本

9.0.41

1.3 maven

D:\Program Files (x86)\apache-maven-3.6.0\bin>mvn --version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: D:\Program Files (x86)\apache-maven-3.6.0\bin\..
Java version: 1.8.0_292, vendor: AdoptOpenJDK, runtime: D:\Program Files (x86)\.jdks\adopt-openjdk-1.8.0_292\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

2 下载源码

http://tomcat.apache.org/

https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.41/src/apache-tomcat-9.0.41-src.zip

Tomcat源码分析环境搭建

Tomcat源码分析环境搭建


3 改造为maven工程

<?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>tomcat9</artifactId>
  <name>tomcat-9.0.41</name>
  <version>9.0.41</version>

  <build>
    <finalName>tomcat-9.0.41</finalName>
    <sourceDirectory>java</sourceDirectory>
    <!-- test 下的有些文件报错,因此将test文件夹去掉了
    <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>3.6.0</version>
        <configuration>
          <encoding>UTF-8</encoding>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.0.2</version>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant</artifactId>
      <version>1.9.5</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/biz.aQute.bnd/biz.aQute.bndlib -->
    <dependency>
      <groupId>biz.aQute.bnd</groupId>
      <artifactId>biz.aQute.bndlib</artifactId>
      <version>5.2.0</version>
      <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-jasper -->
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-jasper</artifactId>
      <version>9.0.41</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant-apache-log4j</artifactId>
      <version>1.9.5</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant-commons-logging</artifactId>
      <version>1.9.5</version>
    </dependency>
    <dependency>
      <groupId>javax.xml.rpc</groupId>
      <artifactId>javax.xml.rpc-api</artifactId>
      <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>wsdl4j</groupId>
      <artifactId>wsdl4j</artifactId>
      <version>1.6.2</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jdt.core.compiler</groupId>
      <artifactId>ecj</artifactId>
      <version>4.6.1</version>
    </dependency>
  </dependencies>

</project>

4 添加vm-options

-Duser.language=en
-Duser.region=US
-Dfile.encoding=UTF-8
-Dsun.jnu.encoding=UTF-8

5 启动tomcat

org.apache.catalina.startup.Bootstrap#main

上一篇:mydumper


下一篇:测试平台系列(41) 编写数据构造器功能(上)