作者:欧美盛 | 来源:互联网 | 2022-11-24 11:59
我开发了一个spring boot
应用程序,我将以下条目放入src/main/resources/application.properties
:
spring.mvc.view.prefix: /
spring.mvc.view.suffix: .jsp
server.port=5000
现在,当我mvn clean spring-boot:run
在本地启动它()时,我正在获取输出,Tomcat started on port(s): 5000 (http)
并且可以在浏览器的http:// localhost:5000/welcome下访问该应用程序.
我Java
在Amazon Elastic Bean Stalk中创建了一个实例,我上传了war
,我甚至在EC2实例的相应安全组中打开了端口5000:

但是当我现在去http://my-aws-ebs-instance.com/welcome:5000时,我收到以下消息:

Whitelabel错误页面此应用程序没有/ error的显式映射,因此您将此视为回退.
Thu Dec 20 16:30:33 UTC 2018出现意外错误(type = Not Found,status = 404)./welcome.jsp
为什么哦为什么会这样发生?我忘了配置什么?
- - 编辑
根据要求,这是根java类:
package com.hellokoding.auth;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
@SpringBootApplication
public class WebApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(WebApplication.class, args);
}
}
这是我的项目的结构与突出显示的welcome.jsp
页面:

当我解压缩生成的war
文件时,这是我硬盘上的文件结构:

我的pom.xml
档案:
4.0.0
auth
auth
my descr
war
org.springframework.boot
spring-boot-starter-parent
1.3.5.RELEASE
UTF-8
1.7
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-data-jpa
org.hsqldb
hsqldb
runtime
org.springframework.boot
spring-boot-starter-tomcat
provided
org.apache.tomcat.embed
tomcat-embed-jasper
provided
log4j
log4j
1.2.17
javax.servlet
jstl
org.springframework.boot
spring-boot-maven-plugin
org.apache.maven.plugins
maven-compiler-plugin
8
8
并且UserController
该类包含:
...
@Controller
@Scope("session")
public class UserController {
@RequestMapping(value = {"/", "/welcome"}, method = RequestMethod.GET)
public String welcome(Model model) {
return "welcome";
}
...
我在welcome
方法中添加了一些日志,我发现它运行正常.此外,在日志文件中,我可以看到以下条目:
Mapped "{[/ || /welcome],methods=[GET]}" onto public java.lang.String com.hellokoding.auth.web.UserController.welcome(org.springframework.ui.Model)
所以我不知道为什么这个东西不起作用.在尝试了11个小时以使其工作之后,我正在质疑我的生活选择,而且我想知道为什么有人会使用这样一个愚蠢的框架,因为它不起作用ootb.
---编辑:
我已经将简化代码上传到github https://github.com/nalogowiec/springbootProblem