java - 将 Springboot WAR 部署到 Tomcat 8.5 显示空白页面
问题描述
我可以使用 tomcat 管理器成功地将 Springboot WAR 包部署/取消部署到 Tomcat 8.5,但是当我尝试打开网页时,它只显示空白页。我想念什么?
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>myapplication</artifactId>
<packaging>war</packaging>
<version>0.0.2</version>
<name>myapplication</name>
<description>My Application</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- exclude tomcat-jdbc, Spring Boot will use HikariCP automatically -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.2.2.jre8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
POM.xml 有什么问题吗?
下面也是我的 application.properties
server.servlet.context-path=/myapplication
我已经尝试删除上下文路径并再次重建它,但它仍然是一样的。
解决方案
显然我必须在 POM.xml 中附加这个依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
我也必须添加这个
@SpringBootApplication
public class SpringBootTomcatApplication extends SpringBootServletInitializer {
}
现在它正在工作,谢谢。
推荐阅读
- angular - RxJS 去抖时间运算符的反转?
- azure - 无法从逻辑应用查看 Azure Functions
- if-statement - if 语句与值匹配
- ruby - 如何修复服务器上 Sinatra 的损坏依赖项
- reactjs - 如何获取具有更改参数的 URL 的 API
- javascript - Tumblr 默认点赞按钮不呈现“点赞”
- scala - 重写 LogicalPlan 以从聚合中下推 udf
- sql-server - 如何使用 EF Core 在 Visual Studio 中为 SQL Server 数据库视图建模?
- python - 为什么类中定义的函数在其他代码片段中不可见?
- mysql - 如何在 php myqsl 中按年龄创建员工分组