【环境】
1.Mac
2.IntelliJ IDEA 2021.3 (Community Edition)
3.JDK 1.8.0_271
4.Ant 1.9.15
【下载Tomcat8.5源码】
image.png image.png
【解压】
image.png
新建一个catalina-home目录
image.png1.目录名称没有特殊要求
2.目录存放的位置没有特殊要求
把webapps目录和conf目录移动到catalina-home目录下. 同时删除test目录
apache-tomcat-8.5.76-src目录内容 移动目录【创建pom.xml文件】
在源码根目录下创建一个pom.xml文件
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>org.apache.tomcat</groupId>
<artifactId>Tomcat</artifactId>
<name>Tomcat</name>
<version>8.5</version>
<build>
<finalName>Tomcat8.5</finalName>
<sourceDirectory>java</sourceDirectory>
<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>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>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.4</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>
</dependencies>
</project>
【导入到IDEA】
导入完成之后, 找到ContextConfig类的configureStart方法,添加一行代码 context.addServletContainerInitializer(new JasperInitializer(), null);
image.png【启动】
启动类 org.apache.catalina.startup.Bootstrap
添加参数
-Dcatalina.home=/Users/infuq/Downloads/Repository/catalina-home
-Dcatalina.base=/Users/infuq/Downloads/Repository/catalina-home
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=/Users/infuq/Downloads/Repository/catalina-home/conf/logging.properties
image.png
启动成功
image.png
http://127.0.0.1:8080访问正常
image.png
网友评论