maven部署
下载源码
步骤
-
源码根目录新建 home 文件夹
-
把 conf 文件夹和 webapps 文件夹移动到 home 文件夹
-
把 homewebappsexamplesWEB-INFclasses railers 目录拷贝到 test railers 目录下(没有自己创建)
-
把 homewebappsexamplesWEB-INFclassesutilCookieFilter.java 文件拷贝到 testutil 目录下
-
修改
org.apache.catalina.startup.ContextConfig
文件的configureStart()
方法添加初始化 JSP 解析器的代码
context.addServletContainerInitializer(new JasperInitializer(), null);
-
在源码根目录新建 pom.xml 文件
设置jdk为1.8, 以及一些必要的依赖
<?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>tomcat</artifactId> <name>tomcat</name> <version>9.0.19</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant</artifactId> <version>1.10.5</version> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.6.3</version> </dependency> <!-- https://mvnrepository.com/artifact/javax.xml.soap/javax.xml.soap-api --> <dependency> <groupId>javax.xml.soap</groupId> <artifactId>javax.xml.soap-api</artifactId> <version>1.4.0</version> </dependency> <!-- <dependency>--> <!-- <groupId>javax.xml</groupId>--> <!-- <artifactId>jaxrpc</artifactId>--> <!-- <version>1.1</version>--> <!-- </dependency>--> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-jaxrpc_1.1_spec</artifactId> <version>2.1</version> </dependency> <!-- <dependency>--> <!-- <groupId>org.eclipse.jdt.core.compiler</groupId>--> <!-- <artifactId>ecj</artifactId>--> <!-- <version>4.5</version>--> <!-- </dependency>--> <dependency> <groupId>org.eclipse.jdt</groupId> <artifactId>ecj</artifactId> <version>3.17.0</version> </dependency> <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> <version>4.0.2</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <!-- <plugin>--> <!-- <groupId>org.apache.maven.plugins</groupId>--> <!-- <artifactId>maven-compiler-plugin</artifactId>--> <!-- <configuration>--> <!-- <source>1.8</source>--> <!-- <target>1.8</target>--> <!-- <encoding>UTF-8</encoding>--> <!-- </configuration>--> <!-- </plugin>--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build> </project>
-
idea打开该根目录
- 标记sources和tests
-
maven导入
右键
pom.xml
-
启动tomcat9
找到
org.apache.catalina.startup.Bootstrap
运行 main 方法, 之后报错停止 -
设置下 jvm 参数
换成自己的目录
-Dcatalina.home=F:Java_Projectidea omcat-masterhome -Dcatalina.base=F:Java_Projectidea omcat-masterhome -Djava.io.tmpdir=F:Java_Projectidea omcat-masterhome emp -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=F:Java_Projectidea omcat-masterhomeconflogging.properties
-
控制台乱码问题
用11就没问题, 把这两个改成1.8控制台就乱码...
参考博客
*====================================================================================================*