对于整个嵌入式tomcat设置我还是很陌生。我正在一个项目中,该项目将tomcat嵌入应用程序中,我进一步希望将其部署为Java Web Start文件。 所以我遇到了一个错误,它要求我检查日志记录,并且没有以前的经验,我绝对不知道如何做。 如果你们中的任何一个可以帮助我,那就太好了。 我正在使用带有内置Maven的日食光子。
谢谢, 诺埃尔(Noel)
我的应用代码...
package com.TomCat.EmbTC;
import java.io.File;
import javax.servlet.ServletException;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;
public class App {
public static void main(String[] args) throws LifecycleException,
InterruptedException,
ServletException {
String docBase = "src/main/webapp/";
Tomcat tomcat = new Tomcat();
String webPort = System.getenv("PORT");
if(webPort == null || webPort.isEmpty()) {
webPort = "8111";
}
tomcat.setPort(Integer.valueOf(webPort));
tomcat.addWebapp("/", new File(docBase).getAbsolutePath());
System.out.println("configuring app with basedir: " + new File("./" +
docBase).getAbsolutePath());
tomcat.start();
tomcat.getServer().await();
}
}
我的pom.xml文件...
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.TomCat</groupId>
<artifactId>EmbTC</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>EmbTC Maven Webapp</name>
<url>http://maven.apache.org</url>
<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>
<tomcat.version>8.5.5</tomcat.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${tomcat.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>${tomcat.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper-el</artifactId>
<version>${tomcat.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jsp-api</artifactId>
<version>${tomcat.version}</version>
</dependency>
</dependencies>
<build>
<finalName>EmbTC</finalName>
</build>
</project>