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
Three ways to define functions in JS Let me expla...
Table of contents 1. System Information 2. Shutdo...
1 Introduction Thread technology was proposed as ...
Summarize Global environment ➡️ window Normal fun...
Download Nginx image in Docker docker pull nginx ...
High CPU load caused by MySQL This afternoon, I d...
Copy code The code is as follows: <select> ...
In MySQL, the LOAD_FILE() function reads a file a...
This article shares the specific code of the appl...
Before using jQuery to complete the fade-in and f...
In a cluster with master-slave replication mode, ...
Table of contents 1. Docker configuration 2. Crea...
Preface Relational databases are more likely to b...
Table of contents 1. Project environment: 2: DNS ...
At this time, you can use overflow:auto; (when the...