[英]Spring Boot / Tomcat on AWS Elastic Beanstalk only showing 404 page
I have a Spring Boot app that runs fine on my localhost under Tomcat. 我有一个Spring Boot应用程序,可以在Tomcat下的localhost上正常运行。 When I package it as a WAR and deploy it on Elastic Beanstalk, I only get the 404 pages.
当我将其打包为WAR并将其部署在Elastic Beanstalk上时,我只获得404页面。 I have tried many different tweaks to try to get it to work but I am at a loss.
我尝试了许多不同的调整试图让它工作,但我不知所措。
I have configured the packaging as a WAR, and IntelliJ generates the artifact: 我已将包装配置为WAR,IntelliJ生成工件:
<groupId>com.ideaEngine</groupId>
<artifactId>app_deployment</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<start-class>com.xxxxxxxx.WebappApplication</start-class>
<java.version>1.8</java.version>
</properties>
I have also included Tomcat as 我也把Tomcat包括在内
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
Elastic Beanstalk server is 64bit Amazon Linux 2016.03 v2.2.0 running Tomcat 8 Java 8 Elastic Beanstalk服务器是运行Tomcat 8 Java 8的64位Amazon Linux 2016.03 v2.2.0
Localhost JVM is jdk1.8.0_71.jdk Localhost JVM是jdk1.8.0_71.jdk
The application object is: 应用程序对象是:
@SpringBootApplication
public class WebappApplication {
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebappApplication.class);
}
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(WebappApplication.class, args);
System.out.println("Running............");
}
}
I have a test controller that I use to make sure everything's working: 我有一个测试控制器,我用它来确保一切正常:
@RestController
public class HelloController {
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
}
...and it generates 404 errors. ...它会产生404错误。
I have named the .war file as Webapp.war, and as ROOT.war, and have tried accessing it at .com/ and /ROOT/ and /Webapp/ 我已将.war文件命名为Webapp.war,并将其命名为ROOT.war,并尝试在.com /和/ ROOT /和/ Webapp /中访问它
All of them produce 404. 他们都生产404。
The log file shows that the app is deploying to the server: 日志文件显示应用程序正在部署到服务器:
Deployment of web application directory /var/lib/tomcat8/webapps/ROOT has finished in 2,143 ms
All the files are unzipped in /var/lib/tomcat8/webapps/ROOT when it's deployed. 部署后,所有文件都在/ var / lib / tomcat8 / webapps / ROOT中解压缩。
The META-INF/MANIFEST.MF seems fine: Manifest-Version: 1.0 Implementation-Title: xxxxxxxxxxx Implementation-Version: 0.0.1-SNAPSHOT Built-By: cdc Implementation-Vendor-Id: com.xxxxxxxxx Created-By: IntelliJ IDEA Build-Jdk: 1.8.0_71 Main-Class: com.xxxxxxxxx.WebappApplication META-INF / MANIFEST.MF似乎很好:清单 - 版本:1.0实现 - 标题:xxxxxxxxxxx实现 - 版本:0.0.1-SNAPSHOT内置:cdc实现 - 供应商-Id:com.xxxxxxxxx创建者:IntelliJ IDEA Build-Jdk:1.8.0_71 Main-Class:com.xxxxxxxxx.WebappApplication
Health reads as "OK" 健康读作“好”
Environment health has transitioned from Info to Ok. Application update completed 58 seconds ago and took 15 seconds.
I've been combing all the other questions relating to deployment on AWS and have come up empty. 我一直在梳理有关AWS部署的所有其他问题,并且已经空洞。
Again, the app runs fine on my local machine. 再次,该应用程序在我的本地计算机上运行良好。
Any ideas as to what I'm missing? 关于我缺少什么的任何想法?
Thanks! 谢谢!
So I had a similar problem to this. 所以我遇到了类似的问题。 I followed the instructions by mkyong https://www.mkyong.com/spring-boot/spring-boot-deploy-war-file-to-tomcat/ and that seemed to solve my problem.
我按照mkyong https://www.mkyong.com/spring-boot/spring-boot-deploy-war-file-to-tomcat/的说明进行操作,这似乎解决了我的问题。
Looking at your code I noticed your WebappApplication isn't extending SpringBootServletInitializer . 看看你的代码,我注意到你的WebappApplication没有扩展SpringBootServletInitializer 。 Maybe try extending SpringBootServletInitializer like so.
也许尝试像这样扩展SpringBootServletInitializer。
@SpringBootApplication
public class WebappApplication extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebappApplication.class);
}
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(WebappApplication.class, args);
System.out.println("Running............");
}
}
It's all detailed in that article. 这篇文章中都详细介绍了这一点。 Hope this helps!
希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.