在查阅了各种资料后,记录一下Tomcat源码运行的过程。
1、下载源码;
在官网选择对应的版本下载源码,这里下载的是8.5.70,解压打开文件
2、新建home文件夹,将源码中的conf和webapp文件夹放到新的home文件夹下;
![在这里插入图片描述](https://img-blog.csdnimg.cn/db566a04139442e582584417a3779172.pn
3编写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>Tomcat8.0</artifactId>
<name>Tomcat8.0</name>
<version>8.0</version>
<build>
<finalName>Tomcat8.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>3.1</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>
4、添加Application并设置VM参数;
-Dcatalina.home=F:/idea_project/tomcat/apache-tomcat-8.5.70-src/apache-tomcat-8.5.70-src/home
-Dcatalina.base=F:/idea_project/tomcat/apache-tomcat-8.5.70-src/apache-tomcat-8.5.70-src/home
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=F:/idea_project/tomcat/apache-tomcat-8.5.70-src/apache-tomcat-8.5.70-src/home/conf/logging.properties
5、点击运行,打开浏览器输入localhost:8080;
发现报错了
在ContextConfig.java文件的configureStart方法内webConfig()下面新增一行代码
context.addServletContainerInitializer(new JasperInitializer(), null);
6、再次浏览localhost:8080;
|