PrefaceRecently, I was analyzing the startup process of Tomcat. Although we can view the source code of Tomcat in idea, we cannot make some code comments on it, which is very inconvenient. So we can still run a copy of the source code locally, which is very helpful for us to analyze the source code. 1. Download the tomcat source code and select tomcat-8.5.55 versionGo to the tomcat official website, click the corresponding version in the left menu bar Download, and download the source code 2. Create a project in idea1. Create a blank project in idea named tomcat_study 2. Open the project source directory and unzip the tomcat source code into it 3. Create a folder Create a home directory under the tomcat source code folder, cut the conf directory and webapps directory in the source code into it (other newly created directories such as logs, etc.), and also create a new maven pom.xml file. 4. Contents of pom.xml file <?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.55</artifactId> <name>Tomcat8.5.55</name> <version>8.5.55</version> <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>org.apache.ant</groupId> <artifactId>ant</artifactId> <version>1.9.5</version> </dependency> <dependency> <groupId>javax.xml.rpc</groupId> <artifactId>javax.xml.rpc-api</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.6.2</version> </dependency> <dependency> <groupId>org.eclipse.jdt.core.compiler</groupId> <artifactId>ecj</artifactId> <version>4.5.1</version> </dependency> </dependencies> <build> <finalName>Tomcat8.5.55</finalName> <sourceDirectory>java</sourceDirectory> <resources> <resource> <directory>java</directory> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <encoding>UTF-8</encoding> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project> 5. Tomcat startup configuration 5.1 Build the project After completing the above operations, we reopen the project in idea, directly select the pom.xml file we added, and after downloading all the packages, build the project structure. 5.2 Setting Run/Debug configurations in Main class: org.apache.catalina.startup.Bootstrap Modify VM options according to your own path: -Dcatalina.home=G:/projects/tomcat_study/apache-tomcat-8.5.55-src/home -Dcatalina.base=G:/projects/tomcat_study/apache-tomcat-8.5.55-src/home -Djava.endorsed.dirs=G:/projects/tomcat_study/apache-tomcat-8.5.55-src/home/endorsed -Djava.io.tmpdir=G:/projects/tomcat_study/apache-tomcat-8.5.55-src/home/temp -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=G:/projects/tomcat_study/apache-tomcat-8.5.55-src/home/conf/logging.properties 5.3 Setting up the ContextConfig class Then open the ContextConfig class (under org.apache.catalina.startup) and add a line of code: context.addServletContainerInitializer(new JasperInitializer(),null); 5.4 Start Tomcat You can debug and view the initialization and startup process of tomcat and other source code execution. The entry class is the main method of the Bootstrap class. SummarizeThrough the above process, we can run the tomcat source code locally through maven. The editor has successfully run it and annotated the process of calling servlet initialization in tomcat. This is the end of this article on how to run tomcat source code in maven mode. For more relevant content about running tomcat source code in maven mode, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: CSS Houdini achieves dynamic wave effect
>>: Xhtml special characters collection
Table of contents Scene Introduction Plugin Imple...
1. Connect to MYSQL Format: mysql -h host address...
The application of containers is becoming more an...
To achieve the association of the frame window, th...
This article shares the specific code of js to ac...
mysql set to case insensitive Windows Go to the d...
CSS style rule syntax style is the basic unit of ...
The MySQL built-in date function TIMESTAMPDIFF ca...
need Recently, we need to migrate Node online ser...
Isolation of process address spaces is a notable ...
Table of contents 1 Version and planning 1.1 Vers...
The user organization has two Windows Server 2008...
ENV: [root@centos7 ~]# uname -r 3.10.0-514.el7.x8...
Preface This control will have a watermark at the...
Table of contents Combining lookahead and lookbeh...