Deploying Spring Boot Jar Application on Beanstalk Java SE Platform

Autumn
1 min readApr 16, 2018

--

In this article, we’re going to take a look at how to deploy executable jar spring boot application to beanstalk java se platform, not tomcat platform.

1. Creating an executable jar

To create spring boot executable jar, you should use build tool to support spring boot packing. Here’s two ways depends on what you use.

Maven

  1. add the spring-boot-maven-plugin to pom.xml
  2. run mvn package
  3. myapplication.jar is created in target directory

Gradle

  1. add the spring-boot-gradle-plugin to build.gradle
  2. run ./gradlew bootJar
  3. myapplication.jar is created in build/lib directory

2. Procfile

Basically, beanstalk can run your application without Procfile in your source bundle if you have a only one jar file. In this case, beanstalk will run it with java -jar myapplication.jar without any jvm options. If you want to customize the java command to set jvm options, you should include Procfile in your source bundle even though only one jar use.

web: java -Dfile.encoding=UTF-8 -Xms2g -Xmx2g -jar myapplication.jar

3. Create a source bundle

Then, we should create a source bundle include myapplication.jar Procfile and .ebextensions if you want to apply settings. Note that Procfile and .ebextensions should be in your source bundle root.

zip -r my_source_bundle.zip myapplication.jar .ebextensions Procfile

4. Deploying source bundle

Now, You can deploy the source bundle to beanstalk with eb deploy EB CLI or Beanstalk web consol. if you use eb deploy EB CLI, you should deploy artifact which is source bundle in .elasticbeanstalk/config.yml

deploy:
artifact:
my_source_bundle.zip

--

--