tomcat 10 源码编译

tomcat 10 源码编译

下载tomcat10源码

在这里插入图片描述

引入 pom.xml

tomcat 10 编译需要jdk10 以上

<?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>com.github.sources</groupId>
  <artifactId>source-tomcat</artifactId>
  <version>10.0-SNAPSHOT</version>
  <name>source-tomcat</name>
  <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.5.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant</artifactId>
      <version>1.10.1</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</groupId>
      <artifactId>org.eclipse.jdt.core</artifactId>
      <version>3.25.0</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jdt.core.compiler</groupId>
      <artifactId>ecj</artifactId>
      <version>4.6.1</version>
    </dependency>
     
    <!-- 用于转换, 需要自行编译 install 到本地库-->
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>jakartaee-migration</artifactId>
      <version>1.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>biz.aQute.bnd</groupId>
      <artifactId>biz.aQute.bndlib</artifactId>
      <version>5.2.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <finalName>Tomcat10.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>3.8.1</version>
        <configuration>
          <encoding>UTF-8</encoding>
          <source>10</source>
          <target>10</target>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>

编译 jakartaee-migration.jar

$ git clone https://github.com/apache/tomcat-jakartaee-migration.git
$ cd tomcat-jakartaee-migration/
$ mvn clean install

注释报错代码, JDTCompiler.java :

//            } else if(opt.equals("16")) {
//                settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_16);
//                settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_16);
//            } else if(opt.equals("17")) {
//                settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_17);
//                settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_17);

此时已经可以正常启动,但会报 500, JSP 编译报错

在这里插入图片描述

JSP编译报错解决

org.apache.catalina.startup.ContextConfigconfigureStart 方法,加上:

    protected synchronized void configureStart() {
        //omit some code..
        webConfig();
        //加入JSP编译器
        context.addServletContainerInitializer(new JasperInitializer(), null);
        //omit some code...
    }

继续启动, 访问http://localhost:8080:

在这里插入图片描述

good luck!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值