zoukankan      html  css  js  c++  java
  • idea中以maven工程的方式运行tomcat源码

    0. 准备环境 idea+jdk8+tomcat源码

    1.下载tomcat源码:

        http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.46/src/apache-tomcat-8.5.46-src.zip

    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.5</artifactId>
        <name>Tomcat8.5</name>
        <version>8.5</version>
     
        <build>
            <finalName>Tomcat8.5</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>
    pom.xml

    3. 根目录新建catalina-home文件夹,并将conf和webapps文件夹复制到catalina-home目录中,最终目录结构如下图

    4. 配置idea

        4.1 将Main class设置为org.apache.catalina.startup.Bootstrap

        4.2 设置vm启动参数

    -Dcatalina.home=catalina-home
    -Dcatalina.base=catalina-home
    -Djava.endorsed.dirs=catalina-home/endorsed
    -Djava.io.tmpdir=catalina-home/temp
    -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
    -Djava.util.logging.config.file=catalina-home/conf/logging.properties
    vm启动参数

    5. 注释util.TestCookieFilter类,类编译报错

    6. org.apache.catalina.startup.ContextConfig中的configureStart函数中手动将JSP解析器初始化:

            webConfig();
            //org.apache.catalina.startup.Bootstrap的时候没有加载org.apache.jasper.servlet.JasperInitializer,无法编译jsp,导致访问url出现500,新增下行代码
            context.addServletContainerInitializer(new JasperInitializer(), null);

    7. 执行Bootstrap类中main方法,打开浏览器访问localhost:8080,出现熟悉的三脚猫,idea运行tomcat源码完成

  • 相关阅读:
    内核态和用户态的区别
    【Docker官方文档】理解Docker
    dpdk中kni模块
    linux的deamon后台运行
    在C语言中如何嵌入python脚本
    Docker学习之路(三)Docker网络详解
    Docker学习之路(二)DockerFile详解
    fopencookie函数详解
    Docker学习之路(一)
    C/C++代码覆盖率工具gcov、lcov
  • 原文地址:https://www.cnblogs.com/dc-earl/p/11652160.html
Copyright © 2011-2022 走看看