tomcat源码导入idea

·  阅读 2556

对于一个开发者来说,要想提高自己,学习tomcat源码还是很有必要的,但是初学者导入tomcat会遇到一些问题,本文记载着自己 导入tomcat8.0到idea踩过得一些坑。

准备工作

Tomcat源码地址:http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.53/src/apache-tomcat-8.0.53-src.zip
IDEA工具:https://www.jetbrains.com/idea/download
MAVEN:http://maven.apache.org/download.cgi
JDK:JDK我用的是1.8
复制代码

导入idea

1.解压apache-tomcat-8.0.53-src.zip把工程导入idea 2.新建一个pom.xml文件,要把test 注释掉,不然启动会报错

<?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</artifactId>
    <name>tomcat8</name>
    <version>8.0</version>
    <build>
        <finalName>tomcat8</finalName>
        <sourceDirectory>java</sourceDirectory>
        <!--<testSourceDirectory>test</testSourceDirectory>  test-->
        <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.5.1</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ant</groupId>
            <artifactId>ant</artifactId>
            <version>1.6.5</version>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>3.4</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>  
复制代码

启动

设置一下VM

-Dcatalina.home=E:\ideaWorkSpaces\Tomcat8

-Dcatalina.base=E:\ideaWorkSpaces\Tomcat8

-Djava.endorsed.dirs=E:\ideaWorkSpaces\Tomcat8\endorsed

-Djava.io.tmpdir=E:\ideaWorkSpaces\Tomcat8\temp

-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

-Djava.util.logging.config.file=E:\ideaWorkSpaces\Tomcat8\conf\logging.properties

如果启动的时候报以下错误: Error:osgi: [apache-tomcat-8.5.20-src] Invalid value for Bundle-Version, @VERSION@ does not match [0-9]{1,9}(.[0-9]{1,9}(.[0-9]{1,9}(.[0-9A-Za-z_-]+)?)?)? 只需要将@version@改为1.1就可以用了

分类:
阅读
收藏成功!
已添加到「」, 点击更改