将Spring Boot应用程序部署到AWS Beanstalk [英] Deploy Spring Boot app to AWS Beanstalk

查看:751
本文介绍了将Spring Boot应用程序部署到AWS Beanstalk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将Spring Boot项目(最好只是jar)部署到AWS Beanstalk环境的最佳方法是什么。或者我应该将它转换为WAR并以这种方式部署?

What would be the best way to deploy Spring Boot project, preferable just jar, to AWS Beanstalk environment. Or should I just convert it to WAR and deploy it that way?

解决方案:

基本上我做的是:


  1. 创建新类告诉Spring Boot我的应用是一个Web应用程序,我需要创建所有必要的配置:

  1. Created new class to tell Spring Boot that my app is a web app and that I need to create all necessary configs:


public class MyBootWebApp extends SpringBootServletInitializer { 

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return

application.sources(MyBootApp.class);
}
}

application.sources(MyBootApp.class); } }


(2)里面。 pom文件将包装更改为像这样的战争:< packaging> war< / packaging>

(2) inside .pom file changed packaging to war like this: <packaging>war</packaging>

就是这样。

推荐答案

将Spring Boot部署到Beanstalk的最简单方法是使用 Spring Guide 。然后,您只需设置Beanstalk应用程序以使用Tomcat并拖放WAR文件。 AWS负责其余部分。

Easiest way to deploy Spring Boot to Beanstalk is to use the Spring Guide for converting your project to a WAR file. Then you just setup your Beanstalk application to use Tomcat and drag and drop the WAR file. AWS takes care of the rest.

编辑:基于马克西姆所做的事情

EDIT: Based on what Maksim did

步骤1:

public class MyBootWebApp extends SpringBootServletInitializer {
    @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(MyBootApp.class);
    }
}

第2步:更改你的pom.xml使用< packaging> war< / packaging>

Step 2: Change your pom.xml use <packaging>war</packaging>

这篇关于将Spring Boot应用程序部署到AWS Beanstalk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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