gpt4 book ai didi

java - JSP 文件未在 AppEngine 中运行的 Spring Boot 中呈现

转载 作者:太空宇宙 更新时间:2023-11-04 10:59:45 25 4
gpt4 key购买 nike

我有一个使用 Google App Engine 标准运行时运行的 Spring Boot 应用程序。当我尝试从 Controller 渲染 JSP View 时,它没有渲染。

这是我的 Maven 依赖项,

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.8.RELEASE</version>
</dependency>

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
<version>9.0.1</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<scope>provided</scope>
<version>1.2</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>1.5.8.RELEASE</version>
</dependency>

我的 Controller 类尝试呈现calendar.jsp,

@RestController
public class HelloController {

@RequestMapping("/hello")
public String hello()
{
return "calendar";
}
}

应用程序属性

spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp

执行命令时

mvn spring-boot:run

我遇到以下异常

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.NoSuchMethodError: org.apache.catalina.Context.addServletMapping(Ljava/lang/String;Ljava/lang/String;)V
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at com.spring.config.Application.main(Application.java:19) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:527) [spring-boot-maven-plugin-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]

Libraries

Directory Structure

感谢您提前提供的帮助。

最佳答案

在我看来,Spring Boot 依赖 Catalina 作为 servlet 引擎(例如 tomcat)

难道 Google 的应用引擎不支持该功能吗?

尝试阅读此专门与 Spring Boot 和应用程序引擎相关的 Google 指南 https://codelabs.developers.google.com/codelabs/cloud-app-engine-springboot/index.html

您声称这个问题是您返回了一个字符串“hello”,这很奇怪,尝试看看这个 https://hellokoding.com/spring-boot-hello-world-example-with-jsp/

关于java - JSP 文件未在 AppEngine 中运行的 Spring Boot 中呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47018720/

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