Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 11 on AWS beanstalk for Spring boot project

I'm new to Spring Boot and I'm trying to develop an application to later deploy it on AWS beanstalk. I started the project using java 11 but later I discovered that AWS only support java 8. Is it possible to set 'maven.compiler.target' in pom.xml to 1.8 to make it running correctly? Should I have to use Java 1.8 for both development and compile? I would like to use new Java features and library. I would like to have some opinion if someone have same problems. Thanks. Cd

like image 446
Davide C Avatar asked Jan 08 '19 09:01

Davide C


People also ask

Is spring boot compatible with Java 11?

Spring Boot 2.7. 1 (and therefore the latest Spring Framework 5.3. 22) supports Java 17 while also remaining compatible with Java 11 and 8.

Is Elastic Beanstalk outdated?

On July 18, 2022 Elastic Beanstalk set the status of all platform branches based on Amazon Linux AMI (AL1) to retired. For more information, see AL1 platform retirement FAQ in the AWS Elastic Beanstalk Developer Guide.

Can AWS deploy spring boot applications?

Amazon Web Services offers multiple ways to install Spring Boot-based applications, either as traditional web applications (war) or as executable jar files with an embedded web server. The options include: AWS Elastic Beanstalk. AWS Code Deploy.


1 Answers

You can install java 11 on your instances using ebextensions. Just create a folder .ebextensions in your source bundle and add there one file with following name 10_java.config and content:

[UPDATE: fixed formatting of the yaml file]

container_commands:
    100-remove-old-java:
        command: "sudo yum remove -y java-1.8.0-openjdk-headless"
    200-download-rpm-package:
        command: "wget https://d3pxv6yz143wms.cloudfront.net/11.0.4.11.1/java-11-amazon-corretto-devel-11.0.4.11-1.x86_64.rpm "
    300-install-java:
        command: "sudo yum localinstall -y java-11-amazon-corretto-devel-11.0.4.11-1.x86_64.rpm"

This will remove default java 8 and install AWS' distribution of java 11.

like image 99
igor Avatar answered Sep 30 '22 13:09

igor