欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Tomcat8源码编译

程序员文章站 2022-07-14 10:47:36
...

Tomcat8源码下载:

https://mirrors.bfsu.edu.cn/apache/tomcat/tomcat-8/v8.5.57/src/apache-tomcat-8.5.57-src.tar.gz

导入2019.1 IDEA进行配置:

  1. 导入IDEA;
  2. 在根目录下新建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>
        <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>
  1. 右键Add maven project,使得idea识别出该项目为maven项目,并且下载资源包。
  2. 在根目录下新建launch目录,此目录将作为catalina home。
  3. 将根目录下的bin/ conf/ logs/ temp/ webapps/ work/ 剪切到launch下,没有则新建。
    Tomcat8源码编译
  4. 配置运行参数:

org.apache.catalina.startup.Bootstrap

-Dcatalina.home=D:\IdeaProjects\apache-tomcat-8.5.57-src\launch
-Dcatalina.base=D:\IdeaProjects\apache-tomcat-8.5.57-src\launch
-Dfile.encoding=UTF-8
-Duser.region=us
-Duser.language=en

Tomcat8源码编译
7. 运行即可!!恭喜成功。

问题集锦

  • 编译报错java.lang.ClassNotFoundException: listeners.ContextListener,但是还是能运行。

      **删除webapps下的example项目,即可。**
    
  • Error:osgi: [apache-tomcat-8.5.57-src] Invalid value for Bundle-Version, @aaa@qq.com does not match [0-9]{1,9}(.[0-9]{1,9}(.[0-9]{1,9}(.[0-9A-Za-z_-]+)?)?)?

      **@aaa@qq.com=1.1**
    
  • 编译乱码

      **-Duser.region=us
     	-Duser.language=en
     **
    
  • TestCookieFilter 报错找不到这个类CookieFilter

     	**删除这个TestCookieFilter类即可**
    
  • org.apache.jasper.JasperException: java.lang.NullPointerException

      	**
      	org.apache.catalina.startup.Bootstrap 添加代码块:
      	JasperInitializer initializer =new JasperInitializer();
      	**
    
相关标签: tomcat 源码编译