Tomcat源码分析-开篇(Tomcat源码部署运行 Maven方式)

1.下载tomcat源码

我这里下载的是 apache-tomcat-8.0.53-src.zip

 

2.新建maven工程

我这里创建一个maven工程,名称为 apache-tomcat-8.0.53-src

 

3.pom.xml中添加相关依赖

<dependency>
    <groupId>ant</groupId>
    <artifactId>ant</artifactId>
    <version>1.6.5</version>
</dependency>
<dependency>
    <groupId>org.eclipse.birt.runtime.3_7_1</groupId>
    <artifactId>javax.wsdl</artifactId>
    <version>1.5.1</version>
</dependency>

<dependency>
    <groupId>org.eclipse.jdt</groupId>
    <artifactId>org.eclipse.jdt.core</artifactId>
    <version>3.10.0</version>
</dependency>
<dependency>
    <groupId>javax.xml</groupId>
    <artifactId>jaxrpc</artifactId>
    <version>1.1</version>
</dependency>
<dependency>
    <groupId>org.hamcrest</groupId>
    <artifactId>hamcrest</artifactId>
    <version>2.1</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.easymock</groupId>
    <artifactId>easymock</artifactId>
    <version>3.4</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.13</version>
    <scope>test</scope>
</dependency>

 

4.拷贝源码包下的目录
  • 将解压的源码下的 conf目录、webapps目录、拷贝至新建项目的根目录
  • 将解压的源码下的 java目录、test目录 src\main 目录下
  • 删除webapps目录下的 examples 目录(否则启动的过程中会提示找不到类)
目录结构如下:
 
 
5.修改 ContextConfig 中的 configureStart() 方法

在configureStart() 方法末尾添加这行代码: context.addServletContainerInitializer(new JasperInitializer(), null);

 

6.启动

找到BootStarp 类,执行main方法就可以启动tomcat了

 

posted @ 2020-03-17 20:08  cao_xiaobo  阅读(790)  评论(0编辑  收藏  举报