项目导入 代码下载
打开GitHub网站:https://github.com/apache/tomcat
下载对应的zip包
解压对应的压缩包(当然你也可以用工具对其进行解压)
unzip tomcat-master.zip新增一个pom.xml,里面添加如下内容
<?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 "> <modelVersion>4.0.0</modelVersion> <groupId>org.apache.tomcat</groupId> <artifactId>Tomcat9.0</artifactId> <name>Tomcat9.0</name> <version>9.0</version> <build> <finalName>Tomcat9.0</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>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>ant</groupId> <artifactId>ant</artifactId> <version>1.7.0</version> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.6.3</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.6.1</version> </dependency> </dependencies> </project>打开IDEA,使用maven进行导入项目
编辑VM options
-Dcatalina.home=http://www.likecs.com/Users/lonecloud/Documents/code/tomcat-master -Dcatalina.base=http://www.likecs.com/Users/lonecloud/Documents/code/tomcat-master -Djava.endorsed.dirs=~/Doucuments/code/tomcat-master/endorsed -Djava.io.tmpdir=http://www.likecs.com/Users/lonecloud/Documents/code/tomcat-master/temp -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=http://www.likecs.com/Users/lonecloud/Documents/code/tomcat-master/conf/logging.properties -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Djdk.tls.ephemeralDHKeySize=2048上面的地址需要配置你的源码的地址
运行org.apache.catalina.startup.Bootstrap的main方法即可
如果出现如下则说明是正常的
05-Jul-2019 14:57:29.479 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in [704] milliseconds 下期预告我们将会分析org.apache.catalina.startup.Bootstrap源码