标签:src contex root tomcat cti spl xmlns 题解 ada
1. Tomcat源码地址 http://tomcat.apache.org/download-80.cgi,本文使用的Tomcat版本是apache-tomcat-8.5.41-src。
注意:本文的安装目录在E:\apache-tomcat-8.5.41-src,会多次用到,需要替换成自己的。
2. 在apache-tomcat-8.5.41-src根目录下新建pom.xml文件,引入依赖的jar包,文件内容如下
<?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</groupId> <artifactId>tomcat</artifactId> <name>apache-tomcat-8.5.24</name> <version>8.5.24</version> <build> <finalName>Tomcat-8.5.24</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>3.5.1</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> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant</artifactId> <version>1.10.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.6.1</version> </dependency> <!-- https://mvnrepository.com/artifact/org.glassfish/javax.xml.rpc --> <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.xml.rpc</artifactId> <version>3.0.1-b03</version> </dependency> </dependencies> </project>
3. 删除test/util/TestCookieFilter.java,不然启动报错。
4. 在IDEA中选择File -> New -> Project from Existing Sources...,按照Maven项目新建即可。
5. 选择Run -> Edit Configurations
.
Main class:
org.apache.catalina.startup.Bootstrap
VM options:
-Dcatalina.home=E:\apache-tomcat-8.5.41-src -Dcatalina.base=E:\apache-tomcat-8.5.41-src -Djava.endorsed.dirs=E:\apache-tomcat-8.5.41-src/endorsed -Djava.io.tmpdir=E:\apache-tomcat-8.5.41-src/temp -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=E:\apache-tomcat-8.5.41-src/conf/logging.properties
6. 添加jsp初始化程序,org.apache.catalina.startup.ContextConfig.java 类中添加
context.addServletContainerInitializer(new JasperInitializer(), null);
7. 启动访问即可,org.apache.catalina.startup.Bootstrap.java的main方法为启动入口
8. 将web工程添加到Tomcat中看运行的流程,配置项目就和在 server.xml中配置工程是一样的。在E:\apache-tomcat-8.5.41-src\conf下的 server.xml 中的 Host节点添加
<Context docBase="E:/apache-tomcat-8.5.41-src/webapps/ROOT" path="/mytomcat" debug="0" reloadable="true"/>
9. 启动项目,访问http://localhost:8080/
问题解决
如果启动的时候报以下错误: Error:osgi: [apache-tomcat-8.5.41-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就可以用了
参考文章:https://blog.csdn.net/z583773315/article/details/56353311
参考文章:https://juejin.im/post/5b7cd3336fb9a019c112619d
标签:src contex root tomcat cti spl xmlns 题解 ada
原文地址:https://www.cnblogs.com/yangjiming/p/10953710.html