码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat-embeded-core源码编译

时间:2020-02-19 15:11:59      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:sof   dir   hot   prope   exp   software   uil   一个   spec   

使用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包

tomcat-embeded-core源码编译

标签:sof   dir   hot   prope   exp   software   uil   一个   spec   

原文地址:https://www.cnblogs.com/gaofeng-henu/p/12331110.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!