• Tomcat源码Idea maven启动


    一、下载tomcat源码

    https://github.com/apache/tomcat/tree/8.5.x

    二、建立pom

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <project xmlns="http://maven.apache.org/POM/4.0.0"
     3          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     4          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     5 
     6     <modelVersion>4.0.0</modelVersion>
     7     <groupId>org.apache.tomcat</groupId>
     8     <artifactId>Tomcat8.5</artifactId>
     9     <name>Tomcat8.0</name>
    10     <version>8.0</version>
    11 
    12     <build>
    13         <finalName>Tomcat8.5</finalName>
    14         <sourceDirectory>java</sourceDirectory>
    15         <testSourceDirectory>test</testSourceDirectory>
    16         <resources>
    17             <resource>
    18                 <directory>java</directory>
    19             </resource>
    20         </resources>
    21         <testResources>
    22             <testResource>
    23                 <directory>test</directory>
    24             </testResource>
    25         </testResources>
    26         <plugins>
    27             <plugin>
    28                 <groupId>org.apache.maven.plugins</groupId>
    29                 <artifactId>maven-compiler-plugin</artifactId>
    30                 <version>2.3</version>
    31                 <configuration>
    32                     <encoding>UTF-8</encoding>
    33                     <source>1.8</source>
    34                     <target>1.8</target>
    35                 </configuration>
    36             </plugin>
    37         </plugins>
    38     </build>
    39 
    40     <dependencies>
    41         <dependency>
    42             <groupId>junit</groupId>
    43             <artifactId>junit</artifactId>
    44             <version>4.12</version>
    45             <scope>test</scope>
    46         </dependency>
    47         <dependency>
    48             <groupId>org.easymock</groupId>
    49             <artifactId>easymock</artifactId>
    50             <version>3.4</version>
    51         </dependency>
    52         <dependency>
    53             <groupId>ant</groupId>
    54             <artifactId>ant</artifactId>
    55             <version>1.7.0</version>
    56         </dependency>
    57         <dependency>
    58             <groupId>wsdl4j</groupId>
    59             <artifactId>wsdl4j</artifactId>
    60             <version>1.6.2</version>
    61         </dependency>
    62         <dependency>
    63             <groupId>javax.xml</groupId>
    64             <artifactId>jaxrpc</artifactId>
    65             <version>1.1</version>
    66         </dependency>
    67         <dependency>
    68             <groupId>org.eclipse.jdt.core.compiler</groupId>
    69             <artifactId>ecj</artifactId>
    70             <version>4.5.1</version>
    71         </dependency>
    72 
    73     </dependencies>
    74 </project>
    View Code

    编译可能有个测试类过不了。删除即可。

    三、新建catalina-home目录

    • 把webapp文件夹和conf文件夹copy到Catalina-home目录
    • 新建空文件夹temp、log、lib

    四,设置启动参数

    -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

      

    • main class设置为 org.apache.catalina.startup.Bootstrap
    • vm option复制上面的参数主要是设置Catalina的启动目录

     五、启动

     至此,tomcat已经成功启动。

    六、访问tomcat

    发现有NPE

    解决:在Bootstrap中启动jasper,修改代码,在ContextConfig中加入如下代码

    context.addServletContainerInitializer(new JasperInitializer(), null);

    启动成功。

  • 相关阅读:
    [转]创建节约内存的JavaBean
    TCP协议
    redis常用命令
    Windows&Linux常用命令笔记
    二叉树学习笔记
    云计算入门
    redis主从切换
    spring 异步处理request
    ibatis工作原理
    工作了3年的JAVA程序员应该具备什么技能?(转)
  • 原文地址:https://www.cnblogs.com/Brake/p/13192575.html
Copyright © 2020-2023  润新知