环境准备:
tomcat9源码
maven(bin目录加入path系统环境变量)
jdk8
idea
源码构建步骤:
1. 在解压缩的源码目录下新建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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>cn.xxx</groupId> <artifactId>Tomcat9.0</artifactId> <name>Tomcat9</name> <version>9.0</version> <build> <finalName>Tomcat9</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>org.apache.ant</groupId> <artifactId>ant</artifactId> <version>1.10.1</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> <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.5.1</version> <scope>test</scope> </dependency> </dependencies> </project>
2.将项目引入idea
“file->new->module from existing sources->选择pom.xml文件->ok”然后等待maven下载依赖包。
3. 在项目根目录下创建lib文件夹,并把官网二进制安装版tomcat的lib下jar包复制到新建的lib文件夹下。
4. 配置run/debug configure选项
run时需要修改vm.options,设置-Dcatalina.home="F: omcatapache-tomcat-9.0.0.M21-src"。
5、run构建并启动
6、浏览器输入localhost:8080/index.jsp