Tomcat源码分析环境搭建

梦里梦外; 2022-08-28 08:43 291阅读 0赞

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


1 版本

1.1 jdk版本

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

1.2 tomcat版本

9.0.41

1.3 maven

  1. D:\Program Files (x86)\apache-maven-3.6.0\bin>mvn --version
  2. Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
  3. Maven home: D:\Program Files (x86)\apache-maven-3.6.0\bin\..
  4. Java version: 1.8.0_292, vendor: AdoptOpenJDK, runtime: D:\Program Files (x86)\.jdks\adopt-openjdk-1.8.0_292\jre
  5. Default locale: zh_CN, platform encoding: GBK
  6. 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

watermark_type_ZHJvaWRzYW5zZmFsbGJhY2s_shadow_50_text_Q1NETiBA54iqIOWThw_size_20_color_FFFFFF_t_70_g_se_x_16

watermark_type_ZHJvaWRzYW5zZmFsbGJhY2s_shadow_50_text_Q1NETiBA54iqIOWThw_size_20_color_FFFFFF_t_70_g_se_x_16 1


3 改造为maven工程

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5. <modelVersion>4.0.0</modelVersion>
  6. <groupId>org.apache.tomcat</groupId>
  7. <artifactId>tomcat9</artifactId>
  8. <name>tomcat-9.0.41</name>
  9. <version>9.0.41</version>
  10. <build>
  11. <finalName>tomcat-9.0.41</finalName>
  12. <sourceDirectory>java</sourceDirectory>
  13. <!-- test 下的有些文件报错,因此将test文件夹去掉了
  14. <testSourceDirectory>test</testSourceDirectory>
  15. -->
  16. <resources>
  17. <resource>
  18. <directory>java</directory>
  19. </resource>
  20. </resources>
  21. <testResources>
  22. <testResource>
  23. <directory>test</directory>
  24. </testResource>
  25. </testResources>
  26. <plugins>
  27. <plugin>
  28. <groupId>org.apache.maven.plugins</groupId>
  29. <artifactId>maven-compiler-plugin</artifactId>
  30. <version>3.6.0</version>
  31. <configuration>
  32. <encoding>UTF-8</encoding>
  33. <source>1.8</source>
  34. <target>1.8</target>
  35. </configuration>
  36. </plugin>
  37. <plugin>
  38. <groupId>org.apache.maven.plugins</groupId>
  39. <artifactId>maven-jar-plugin</artifactId>
  40. <version>3.0.2</version>
  41. </plugin>
  42. </plugins>
  43. </build>
  44. <dependencies>
  45. <dependency>
  46. <groupId>org.apache.ant</groupId>
  47. <artifactId>ant</artifactId>
  48. <version>1.9.5</version>
  49. </dependency>
  50. <!-- https://mvnrepository.com/artifact/biz.aQute.bnd/biz.aQute.bndlib -->
  51. <dependency>
  52. <groupId>biz.aQute.bnd</groupId>
  53. <artifactId>biz.aQute.bndlib</artifactId>
  54. <version>5.2.0</version>
  55. <scope>provided</scope>
  56. </dependency>
  57. <!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-jasper -->
  58. <dependency>
  59. <groupId>org.apache.tomcat</groupId>
  60. <artifactId>tomcat-jasper</artifactId>
  61. <version>9.0.41</version>
  62. </dependency>
  63. <dependency>
  64. <groupId>org.apache.ant</groupId>
  65. <artifactId>ant-apache-log4j</artifactId>
  66. <version>1.9.5</version>
  67. </dependency>
  68. <dependency>
  69. <groupId>org.apache.ant</groupId>
  70. <artifactId>ant-commons-logging</artifactId>
  71. <version>1.9.5</version>
  72. </dependency>
  73. <dependency>
  74. <groupId>javax.xml.rpc</groupId>
  75. <artifactId>javax.xml.rpc-api</artifactId>
  76. <version>1.1</version>
  77. </dependency>
  78. <dependency>
  79. <groupId>wsdl4j</groupId>
  80. <artifactId>wsdl4j</artifactId>
  81. <version>1.6.2</version>
  82. </dependency>
  83. <dependency>
  84. <groupId>org.eclipse.jdt.core.compiler</groupId>
  85. <artifactId>ecj</artifactId>
  86. <version>4.6.1</version>
  87. </dependency>
  88. </dependencies>
  89. </project>

4 添加vm-options

  1. -Duser.language=en
  2. -Duser.region=US
  3. -Dfile.encoding=UTF-8
  4. -Dsun.jnu.encoding=UTF-8

5 启动tomcat

  1. org.apache.catalina.startup.Bootstrap#main

发表评论

表情:
评论列表 (有 0 条评论,291人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Tomcat分析--

    1.前言 当时看Tomcat源码的初衷是想弄明白它里面的类加载器的那些事,感觉对于动态部署应用,他就废弃旧的类加载器,新建一个新的加载器去加载应用,感觉是一件很神奇的事,