Elastic Beanstalk工人层上的Spring Boot [英] Spring Boot on Elastic Beanstalk worker tier

查看:126
本文介绍了Elastic Beanstalk工人层上的Spring Boot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Spring Boot应用程序部署到一个EB工人层中,但似乎EB尚未准备好管理此类项目.

I am trying to deploy a spring boot app into one EB worker tier but seems that EB it is not ready to manage this kind of project.

我是否必须从我的Spring Boot应用强制生成.war?

Have I to mandatory generate a .war from my spring boot app?

谢谢!

推荐答案

我发现了问题.

EB希望使用.war文件,并且Spring Boot应用程序通常是由嵌入式Tomcat或Jetty启动的.

EB expects a .war file and Spring Boot app usually is launche by a embedded Tomcat or Jetty.

我在本指南中找到了解决方案:

I have found the solution in this guide:

http://spring.io/guides/gs/convert-jar-to-war/

总结:

  1. 使用pom.xml中提供的范围添加tomcat依赖项

  1. Add tomcat dependency with provided scope in pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

  • 创建一个扩展SpringBootServletInitializer的类,并在该类中加载入口点.这样,我们就向servlet容器指示如何启动应用程序.

  • Create a class extending SpringBootServletInitializer and load the entrypoint within this class. This way, we are indicating to the servlet container how to launch the app.

    package com.proyecti.magma.conversionsworker.config.servlet;
    
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.boot.context.web.SpringBootServletInitializer;
    
    import com.proyecti.magma.conversionsworker.entrypoint.Application;
    
    public class ServletConfig extends SpringBootServletInitializer
    {
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(Application.class);
        }
    
    }
    

  • 这篇关于Elastic Beanstalk工人层上的Spring Boot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆