[英]AWS Elastic Beanstalk - Problem with tomcat java spring boot application
[英]Spring Boot / Tomcat on AWS Elastic Beanstalk only showing 404 page
我有一个Spring Boot应用程序,可以在Tomcat下的localhost上正常运行。 当我将其打包为WAR并将其部署在Elastic Beanstalk上时,我只获得404页面。 我尝试了许多不同的调整试图让它工作,但我不知所措。
我已将包装配置为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>
我也把Tomcat包括在内
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
Elastic Beanstalk服务器是运行Tomcat 8 Java 8的64位Amazon Linux 2016.03 v2.2.0
Localhost JVM是jdk1.8.0_71.jdk
应用程序对象是:
@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............");
}
}
我有一个测试控制器,我用它来确保一切正常:
@RestController
public class HelloController {
@RequestMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
}
...它会产生404错误。
我已将.war文件命名为Webapp.war,并将其命名为ROOT.war,并尝试在.com /和/ ROOT /和/ Webapp /中访问它
他们都生产404。
日志文件显示应用程序正在部署到服务器:
Deployment of web application directory /var/lib/tomcat8/webapps/ROOT has finished in 2,143 ms
部署后,所有文件都在/ var / lib / tomcat8 / webapps / ROOT中解压缩。
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
健康读作“好”
Environment health has transitioned from Info to Ok. Application update completed 58 seconds ago and took 15 seconds.
我一直在梳理有关AWS部署的所有其他问题,并且已经空洞。
再次,该应用程序在我的本地计算机上运行良好。
关于我缺少什么的任何想法?
谢谢!
所以我遇到了类似的问题。 我按照mkyong https://www.mkyong.com/spring-boot/spring-boot-deploy-war-file-to-tomcat/的说明进行操作,这似乎解决了我的问题。
看看你的代码,我注意到你的WebappApplication没有扩展SpringBootServletInitializer 。 也许尝试像这样扩展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............");
}
}
这篇文章中都详细介绍了这一点。 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.