gpt4 book ai didi

docker - spring boot mvc docker Whitelabel错误

转载 作者:行者123 更新时间:2023-12-02 07:03:58 26 4
gpt4 key购买 nike

我有一个在 docker 容器上运行的 spring boot mvc 应用程序。容器运行得很好,但是当我尝试在浏览器上访问应用程序时,我收到 Whitelabel 错误页面,指出它找不到/WEB-INF/views/***.jsp。下面是我的 pom.xml

<?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>com.jay.webapp</groupId>
<artifactId>LoginModel</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>LoginModel</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<project.reporting.outputEncoding>UTF8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

下面是我的 Dockerfile

FROM openjdk:8-jdk-alpine 
MAINTAINER "***"
COPY LoginModel-0.0.1-SNAPSHOT.jar app.jar
CMD ["java","-Djava.security.egd=file:/dev/./urandom","-jar","app.jar"]

当我在本地执行“java -jar target/LoginModel-0.0.1-SNAPSHOT.jar”并尝试在浏览器上查看它时,它工作完美,没有任何错误。当我尝试在 docker 容器上运行应用程序时,我只收到错误。究竟错在哪里呢?

最佳答案

您似乎正在使用 JSP,但您的应用程序打包为 JAR。您应该将应用程序打包为 WAR。文档还提到

Creating a custom error.jsp page won’t override the default view for error handling, custom error pages should be used instead.

看看the JSP limitations section in the reference documentation了解更多相关信息。

关于docker - spring boot mvc docker Whitelabel错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47027219/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com