tomcat-embeded-core源码编译

2020-02-19 16:05:34来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

tomcat-embeded-core源码编译

使用spring-boot创建web工程时,默认采用embeded tomcat作为容器,实际使用过程中,可能会需要对其中的某些功能做微调,而tomcat又没有给出预留配 ,这时就需要对tomcat-embed-core源码进行编译了,下面说下具体的步骤

创建工程

  1. 在eclipse中创建tomcat-embed-core的maven工程
  2. 通过maven下载一个自己需要编译的tomcat-embed-core版本对应的source包(以8.5.31为例)
  3. 解压tomcat-embed-core对应的source包
  4. 将source包中javax和org两个包copy到刚创建的maven工程的src/main/java目录下
  5. 将source包中的META-INF放到src/main/resources目录下
  6. 编辑pom文件,追加依赖包、编译内容、以及发布的默认maven仓库
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
    -->
    <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.embed</groupId>
    <artifactId>tomcat-embed-core</artifactId>
    <version>8.5.31-me</version>
    <description>Core Tomcat implementation</description>
    <url>http://tomcat.apache.org/</url>
    <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <dependencies>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-annotations-api</artifactId>
      <version>8.5.31</version>
      <scope>compile</scope>
    </dependency>
    
    <dependency>
      <groupId>javax.mail</groupId>
      <artifactId>javax.mail-api</artifactId>
      <version>1.5.6</version>
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>javax.persistence</groupId>
      <artifactId>javax.persistence-api</artifactId>
      <version>2.2</version>
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>org.glassfish</groupId>
      <artifactId>javax.ejb</artifactId>
      <version>3.1.1</version>
      <scope>provided</scope>
    </dependency>
    
    
    <dependency>
      <groupId>org.apache.tomcat.embed</groupId>
      <artifactId>tomcat-embed-jasper</artifactId>
      <version>8.5.31</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  
  <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                    <include>**/*.xsd</include>
                    <include>**/*.dtd</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
   <distributionManagement>
        <repository>
            <id>my-releases</id>
            <name>my-releases</name>
            <url>http://nexus:8081/repository/my-releases/</url>
        </repository>
        <snapshotRepository>
            <id>my-snapshots</id>
            <name>my-snapshots</name>
            <url>http://nexus:8081/repository/my-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
</project>

编辑修改需要定制化的类

重新打包

进入工程目录执行,maven deploy,会将打包好的jar包上传到对应的maven仓库中

之后其他工程就可以依赖新打出的jar包

原文链接:https://www.cnblogs.com/gaofeng-henu/p/12331110.html
如有疑问请与原作者联系

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:轻量级RPC设计与实现第五版(最终版)

下一篇:SpringBoot整合WEB开发--(八)启动任务系统