{"id":98679,"date":"2019-09-30T09:35:10","date_gmt":"2019-09-30T06:35:10","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=98679"},"modified":"2019-10-14T12:47:49","modified_gmt":"2019-10-14T09:47:49","slug":"easy-spring-boot-deployment-aws-elastic-beanstalk","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2019\/09\/easy-spring-boot-deployment-aws-elastic-beanstalk.html","title":{"rendered":"Easy Spring Boot Deployment with AWS Elastic Beanstalk"},"content":{"rendered":"<p><span style=\"font-size: 20px;\"><strong>Friends don\u2019t let friends write user auth. Tired of managing your own users?<\/strong><a href=\"https:\/\/developer.okta.com\/signup\/?utm_campaign=text_website_all_multiple_dev_dev_spring-boot-aws-elastic_null&amp;utm_source=jcg&amp;utm_medium=cpc\"> Try Okta\u2019s API and Java SDKs today. Authenticate, manage, and secure users in any application within minutes.<\/a><\/span><\/p>\n<p>Nearly all applications rely on authentication. Developers, and the companies that employ them, want to confirm who is making the request and are they who they say they are. And, this needs to happen fast enough for a good user experience. Fortunately, there are great tools to help.<\/p>\n<p>Spring Boot with Spring Security is a fantastic solution for Java-based web development. With relatively little code, developers can implement, test, update, and expand authentication schemes easily and securely.<\/p>\n<p>In this tutorial, you will build a very simple \u201cHello World\u201d app in Spring Boot with OAuth 2.0 \/ OpenID Connect and Okta as the OAuth provider. It will use AWS as the cloud provider, deploying through AWS Elastic Beanstalk.<\/p>\n<h2 class=\"wp-block-heading\" id=\"why-aws-elastic-beanstalk\">Why AWS Elastic Beanstalk?<\/h2>\n<p>When it comes to cloud infrastructure providers, AWS has always been the market leader and their services make it fast and easy to deploy a cloud application. Elastic Beanstalk is a deployment and provisioning service that allows you to deploy an entire infrastructure with a few clicks by automating the process of getting applications set up on AWS infrastructure. Additionally, it helps manage the resource utilization of your app with automatic Provisioning, load balancing, autoscaling, and health monitoring.<\/p>\n<h2 class=\"wp-block-heading\" id=\"create-a-spring-boot-application\">Create a Spring Boot Application<\/h2>\n<p>Before you start a cloud deployment, you\u2019ll need the app itself. The first version of your app will have a simple page, which will show&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Hello, {user}!<\/code>&nbsp;if you input a user\u2019s name, or it will show&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Hello, World!<\/code>&nbsp;otherwise. You\u2019re going to use Spring MVC and Thymeleaf to do the task.<\/p>\n<p>Thymeleaf is a server-side template engine. It allows you to pass server arguments to your HTML before rendering it in the client\u2019s web browser.<\/p>\n<p>Could you create a project from scratch? Sure, but you don\u2019t need to. You can use Spring Initializr instead. It will help you generate your project with all the dependencies you need.<\/p>\n<p><a href=\"https:\/\/start.spring.io\/\">Go to the Spring Initializr website<\/a>, and type the following information:<\/p>\n<pre class=\"gutter: false;brush:bash\">- Project: Maven Project\n- Language: Java\n- Group: com.okta\n- Artifact: hello-world\n- Dependencies: Spring Web Starter, Thymeleaf\n<\/pre>\n<p>You can choose either to generate the project using Maven or Gradle. This tutorial shows the steps using Maven, but you can easily follow it on Gradle.<\/p>\n<p>After you provide the information, click on&nbsp;<strong>Generate the project<\/strong>. The site will generate a zip file you can download and extract. Open the project in your favorite IDE, and you\u2019re good to go!<\/p>\n<h2 class=\"wp-block-heading\" id=\"create-the-web-page\">Create The Web Page<\/h2>\n<p>With Spring MVC, you need to create a Controller to represent the web page. It will map to the endpoint&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">\/hello<\/code>, and also to&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">\/<\/code>, which represents the homepage. It returns the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">hello-world<\/code>&nbsp;template as a response.<\/p>\n<p>Create the class&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">HelloWorldController<\/code>:<\/p>\n<pre class=\"gutter: false;brush:java\">@Controller\npublic class HelloWorldController {\n\n    @GetMapping({\"\/\", \"hello\"})\n    public String helloWorld(@RequestParam(required = false, defaultValue = \"World\") String name, Model model) {\n        model.addAttribute(\"name\", name);\n        return \"hello-world\";\n    }\n}\n<\/pre>\n<p>So far, so good. Next, you create the html template. What is this template, though? Why do you need it?<\/p>\n<p>The template is an HTML page Spring MVC uses to render the information in the user\u2019s browser.<\/p>\n<p>You define a Thymeleaf HTML page to receive all attributes defined in the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">model<\/code>&nbsp;object.<\/p>\n<p>Inside&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">src\\main\\resources\\templates<\/code>, create the file&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">hello-world.html<\/code>:<\/p>\n<pre class=\"gutter: false;brush:xml\">&lt;!DOCTYPE html&gt;\n&lt;html xmlns:th=\"http:\/\/www.thymeleaf.org\"&gt;\n    &lt;body&gt;\n        &lt;h1 th:text=\"'Hello, ' + ${name} + '!'\"&gt;&lt;\/h1&gt;\n    &lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p>This creates an HTML page that displays a&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">&lt;h1&gt;<\/code>&nbsp;tag in the body, with a greeting message. The&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">${name}<\/code>&nbsp;attribute is not native HTML, it is part of Thymeleaf and receives the value from the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">model<\/code>&nbsp;object to render the information before sending it to the browser.<\/p>\n<p>Now you have created both the controller and the template, you can run it, and see if it works! Open the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">HelloWorldApplication<\/code>&nbsp;class and execute the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">main<\/code>&nbsp;method.<\/p>\n<p>Or, from the command line, execute:<\/p>\n<pre class=\"gutter: false;brush:bash\">.\/mvnw spring-boot:run\n<\/pre>\n<p>If you go to&nbsp;<strong>http:\/\/localhost:8080\/<\/strong>&nbsp;in your web browser, you will see the following message:<\/p>\n<pre class=\"gutter: false;brush:bash\">Hello, World!\n<\/pre>\n<p>If you want a custom message, you can add the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">name<\/code>&nbsp;parameter. For instance,&nbsp;<strong>http:\/\/localhost:8080\/?name=Daniel<\/strong>&nbsp;will return:<\/p>\n<pre class=\"gutter: false;brush:bash\">Hello, Daniel\n<\/pre>\n<h2 class=\"wp-block-heading\" id=\"add-spring-security\">Add Spring Security<\/h2>\n<p>When it comes to SaaS, developers want to make sure their application is secure. Users shouldn\u2019t be able to see user data from other users.<\/p>\n<p>Spring Security handles authentication, authorization, and other security aspects. To add it in your project, go to the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">pom.xml<\/code>&nbsp;file, and add the following code inside the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">&lt;dependencies&gt;<\/code>&nbsp;tag:<\/p>\n<pre class=\"gutter: false;brush:xml\">&lt;dependency&gt;\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n    &lt;artifactId&gt;spring-boot-starter-security&lt;\/artifactId&gt;\n&lt;\/dependency&gt;\n<\/pre>\n<p>That\u2019s it! When you add Spring Security as a dependency, it enables security by default. When you try to access your endpoints, you\u2019ll have to log in before continuing.<\/p>\n<p>Let\u2019s test it. Run the application, then go to&nbsp;<strong>http:\/\/localhost:8080\/<\/strong>. You will see the following result:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"383\" height=\"253\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs.png\" alt=\"\" class=\"wp-image-98680\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs.png 383w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-300x198.png 300w\" sizes=\"(max-width: 383px) 100vw, 383px\" \/><\/figure>\n<\/div>\n<p>As expected, now it redirects you to the login page, which will ask for a username and password. You must be asking yourself right now: which username and password should I use?<\/p>\n<p>The default username is&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">user<\/code>. Instead of setting a default password, Spring changes it every time the application starts. You can see the current one by looking at the applications logs. Look for something like this:<\/p>\n<pre class=\"gutter: false;brush:bash\">Using generated security password: 29aa0d09-eaca-47ae-bcad-e5b22affd466\n<\/pre>\n<p>This behavior is not what you want in a real application. Users expect the password to remain the same unless they change it themselves. Let\u2019s add a configuration to make it happen.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Create the class&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">SecurityConfiguration<\/code>:<\/p>\n<pre class=\"gutter: false;brush:java\">@EnableWebSecurity\npublic class SecurityConfiguration extends WebSecurityConfigurerAdapter {\n\n    private PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();\n\n    @Override\n    protected void configure(AuthenticationManagerBuilder auth) throws Exception {\n        auth.inMemoryAuthentication()\n            .passwordEncoder(passwordEncoder())\n            .withUser(\"john.doe\")\n            .password(passwordEncoder().encode(\"secret\"))\n            .roles(\"USER\");\n    }\n\n    @Bean\n    public PasswordEncoder passwordEncoder() {\n        return passwordEncoder;\n    }\n}\n<\/pre>\n<p>The class above extends&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">WebSecurityConfigurerAdapter<\/code>, and allows you to change the authentication management method. In this example, you create a single user, but you can create as many as you want. Just append a new&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">withUser<\/code>&nbsp;call after the first one.<\/p>\n<p>Now that the user has authenticated to your application, you don\u2019t need to ask for a username anymore. Instead, you will display the information based on the current user. Inside the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">HelloWorldController<\/code>, make these changes in the code:<\/p>\n<pre class=\"gutter: false;brush:java\">@Controller\npublic class HelloWorldController {\n\n    @GetMapping({\"\/\", \"hello\"})\n    public String helloWorld(Model model, Principal principal) {\n        model.addAttribute(\"name\", principal.getName());\n        return \"hello-world\";\n    }\n}\n<\/pre>\n<p>The&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Principal<\/code>&nbsp;interface stores the name of the current user. Spring Security takes care of the dirty work: you only need to add it as an argument, and the method receives the correct value.<\/p>\n<p>To see this change, stop the application and run it again. If you access&nbsp;<strong>http:\/\/localhost:8080\/<\/strong>, it will ask you to log in again. Use&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">john.doe<\/code>&nbsp;as the username&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">secret<\/code>&nbsp;as the password. After submitting the information, you will see the following text:<\/p>\n<pre class=\"gutter: false;brush:bash\">Hello, john.doe!\n<\/pre>\n<p>Now you\u2019re ready to deploy your application in the cloud!<\/p>\n<h2 class=\"wp-block-heading\" id=\"deploy-the-application-to-aws-elastic-beanstalk\">Deploy The Application To AWS Elastic Beanstalk<\/h2>\n<p>To deploy the service, you will use AWS Elastic Beanstalk. If you don\u2019t have an AWS account go ahead and&nbsp;<a href=\"https:\/\/portal.aws.amazon.com\/billing\/signup#\/start\">create one here.<\/a><\/p>\n<p>After&nbsp;<a href=\"https:\/\/console.aws.amazon.com\/\">logging into the AWS console<\/a>, go to Services and type&nbsp;<strong>Elastic Beanstalk<\/strong>&nbsp;in the search. Click on it, and it will redirect you to a Welcome page. Click on the&nbsp;<strong>Get started<\/strong>&nbsp;button to start creating your application in the cloud. You will see the following screen:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-02-1024x695.png\" alt=\"\" class=\"wp-image-98681\" width=\"768\" height=\"521\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-02-1024x695.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-02-300x204.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-02-768x521.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-02.png 1054w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>Here you will create a web application. Put the following information in the fields above:<\/p>\n<pre class=\"gutter: false;brush:bash\">Application name:  hello-world\nPlatform: Java\nApplication code: Upload Your code\n<\/pre>\n<p>Before you upload your code you will need to export it as a JAR file. Go inside your application folder and type the following command:<\/p>\n<pre class=\"gutter: false;brush:bash\">.\/mvnw package -DskipTests\n<\/pre>\n<p>After it runs, upload the file&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">hello-world-0.0.1-SNAPSHOT.jar<\/code>&nbsp;under the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">target<\/code>&nbsp;folder.<\/p>\n<p>When the upload completes, click on the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Create application<\/code>&nbsp;button. AWS will start to create the environment, displaying the logs of what is happening in the process.<\/p>\n<p>Once the environment is set up, AWS will redirect you to the Dashboard. Above the dashboard menu, you\u2019ll find the URL to access the application. Open it in a new tab, and it will load your web page.<\/p>\n<p>Right now, you get a&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">502<\/code>&nbsp;error response, which is expected. By default, Elastic Beanstalk runs the application on port 5000, while Spring Boot executes on port 8080. Let\u2019s direct your app run on port 5000 to fix the issue.<\/p>\n<p>Click on&nbsp;<strong>Configuration<\/strong>&nbsp;the dashboard menu. You will see the screen below:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1024\" height=\"455\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-03-1024x455.png\" alt=\"\" class=\"wp-image-98682\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-03-1024x455.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-03-300x133.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-03-768x341.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-03.png 1391w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n<p>You can change many variables and features in your environment: add a load balancer, increase the number of instances, or in this case add environment variables.<\/p>\n<p>Go to the&nbsp;<strong>Software<\/strong>&nbsp;card and click on&nbsp;<strong>Modify<\/strong>. Look for&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Environment properties<\/code>&nbsp;and add the following value to the list:<\/p>\n<p><code style=\"font-size:13px\" class=\"highlighter-rouge\">SERVER_PORT<\/code>&nbsp;:&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">5000<\/code><\/p>\n<p>After changing it, click on the&nbsp;<strong>Apply<\/strong>&nbsp;button and wait for AWS to apply the changes in the environment. When the message&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Environment update completed successfully.<\/code>&nbsp;appears, open the URL again.<\/p>\n<p>Now it worked! Type the username and password you defined in your code,&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">john.doe<\/code>&nbsp;and&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">secret<\/code>. It will then redirect you to the hello page, which will show you the same result as your local environment:<\/p>\n<pre class=\"gutter: false;brush:bash\">Hello, john.doe!\n<\/pre>\n<p>If you have problems, you can always check the logs.<\/p>\n<ul class=\"wp-block-list\">\n<li>In the menu, click on&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Logs<\/code>, which will redirect you to the following page:<\/li>\n<\/ul>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-04-1024x172.png\" alt=\"\" class=\"wp-image-98683\" width=\"768\" height=\"129\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-04-1024x172.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-04-300x50.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-04-768x129.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-04.png 1391w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<ul class=\"wp-block-list\">\n<li>Go to&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Request Logs<\/code>&nbsp;&gt;&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Full Logs<\/code>. This will generate a zip file with all your environment logs<\/li>\n<li>Download and extract the file<\/li>\n<li>Go to&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">var\/log\/rotated<\/code><\/li>\n<li>Over there you\u2019ll find another zip file from your app. Extract it, then open the extracted file to see the applications logs<\/li>\n<\/ul>\n<p>Did everything work so far? Congratulations, you have your first Spring Boot application running in the cloud! Awesome, isn\u2019t it? But wait, you still have work to do before you can celebrate.<\/p>\n<h2 class=\"wp-block-heading\" id=\"make-your-application--security-production-ready\">Make Your Application Security Production-Ready<\/h2>\n<p>Remember you created a user and put the credentials inside your code? This strategy might work for testing purposes, but it\u2019s a huge no-go for real applications.<\/p>\n<p>Handling identity management is not a trivial task, and you\u2019ll want to use a service instead of \u201crolling your own\u201d.<\/p>\n<p>Okta is an excellent identity management service, which provides an identity provider, authentication, authorization and user security out of the box. Let\u2019s configure your application to use it.<\/p>\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.okta.com\/signup?utm_campaign=text_website_all_multiple_dev_dev_spring-boot-aws-elastic_null&amp;utm_source=jcg&amp;utm_medium=cpc\">Create an Okta account<\/a><\/li>\n<li>Login into your account<\/li>\n<li>Click&nbsp;<strong>Applications<\/strong><\/li>\n<li>Click&nbsp;<strong>Add Application<\/strong><\/li>\n<\/ul>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-05-1024x721.png\" alt=\"\" class=\"wp-image-98684\" width=\"768\" height=\"541\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-05-1024x721.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-05-300x211.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-05-768x541.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-05.png 1999w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<ul class=\"wp-block-list\">\n<li>Select&nbsp;<strong>Web<\/strong>&nbsp;and click on the&nbsp;<strong>Next<\/strong>&nbsp;button.<\/li>\n<li>Fill in the following options into the form:<\/li>\n<\/ul>\n<pre class=\"gutter: false;brush:bash\">Name: hello-world\nBase URIs: http:\/\/localhost:8080\/, ${BEANSTALK_URL}\nLogin redirect URLs: http:\/\/localhost:8080\/login\/oauth2\/code\/okta, ${BEANSTALK_URI}\/login\/oauth2\/code\/okta\nGrant Type allowed: Client Credentials. Authorization Code\n<\/pre>\n<p>Change&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">${BEANSTALK_URL}<\/code>&nbsp;to your AWS environment URL. For instance, my value is&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">HelloWorld-env.t3z2mwuzhi.us-east-1.elasticbeanstalk.com<\/code>.<\/p>\n<p>Great! You whitelisted your local and production environments. If you make calls to your Okta application from them, it will permit the request.<\/p>\n<h2 class=\"wp-block-heading\" id=\"secure-the-application-with-okta-and-oauth-20\">Secure The Application With Okta and OAuth 2.0<\/h2>\n<p>With your application in Okta, you need to change the code to start using it. Okta handle the authentication for you from now on.<\/p>\n<p>Replace the Spring Security dependency inside your&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">pom.xml<\/code>&nbsp;file with the okta dependency, which itself includes Spring Security. Put the following code inside the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">&lt;dependencies&gt;<\/code>&nbsp;tag:<\/p>\n<pre class=\"gutter: false;brush:xml\">&lt;dependency&gt;\n    &lt;groupId&gt;com.okta.spring&lt;\/groupId&gt;\n    &lt;artifactId&gt;okta-spring-boot-starter&lt;\/artifactId&gt;\n    &lt;version&gt;1.2.1&lt;\/version&gt;\n&lt;\/dependency&gt;\n<\/pre>\n<p>The library will handle the communication between your application and Okta. All that you have to do is identify your Okta information. Set the following environment variables locally:<\/p>\n<pre class=\"gutter: false;brush:java\">OKTA_OAUTH2_ISSUER={ORG_URL}\/oauth2\/default\nOKTA_OAUTH2_CLIENT_ID={CLIENT_ID}\nOKTA_OAUTH2_CLIENT_SECRET={CLIENT_SECRET}\n<\/pre>\n<p>Great! You whitelisted your local and production environments. If you make calls to your Okta application from those places, it will permit the request.<\/p>\n<p>Your&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">{ORG_URL}<\/code>&nbsp;will be visible in your Okta dashboard, just click on&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Dashboard<\/code>&nbsp;in the menu. You will see the Org URL in the right upper corner.<\/p>\n<p>You can find&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">{CLIENT_ID}<\/code>&nbsp;and&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">{CLIENT_SECRET}<\/code>&nbsp;in your Okta application:<\/p>\n<ul class=\"wp-block-list\">\n<li>In your Okta\u2019s menu, go to&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Applications<\/code><\/li>\n<li>Select the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">hello-world<\/code>&nbsp;application<\/li>\n<li>Click on the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">General<\/code>&nbsp;tab<\/li>\n<li>Scroll down to&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Client Credentials<\/code><\/li>\n<\/ul>\n<p>There you\u2019ll see both the client id and secret.<\/p>\n<p>With these changes, you now authenticate with OpenID Connect. When the user goes to the homepage, your application will redirect her to your Okta login page, then back to webpage.<\/p>\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p> OpenID Connect is a thin layer on top of the OAuth 2.0 authorization framework and is focused on identity and authentication. <\/p>\n<\/blockquote>\n<p>With OpenID Connect, you need to change the way you receive the authenticated user. Go to the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">HelloWorldController<\/code>&nbsp;class and update the code:<\/p>\n<pre class=\"gutter: false;brush:java\">@Controller\npublic class HelloWorldController {\n\n    @GetMapping({\"\/\", \"hello\"})\n    public String helloWorld(Model model, @AuthenticationPrincipal OidcUser user) {\n        model.addAttribute(\"name\", user.getGivenName());\n        return \"hello-world\";\n    }\n}\n<\/pre>\n<p>This still passes authentication information to Thymeleaf using the model, but moves from using&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Principal<\/code>&nbsp;to use&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">OidcUser<\/code>. This allows you to retrieve any attribute you want. In this example, we want the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">given_name<\/code>&nbsp;attribute.<\/p>\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p> <strong>NOTE:<\/strong>&nbsp;Since you are using Okta to authenticate, you don\u2019t need your old configuration anymore. Go ahead and delete the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">SecurityConfiguration<\/code>&nbsp;class. <\/p>\n<\/blockquote>\n<p>Let\u2019s run the application! Start it again and go to&nbsp;<strong>http:\/\/localhost:8080\/<\/strong>. Notice you\u2019re redirected to the Okta login page:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"406\" height=\"513\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-06.png\" alt=\"\" class=\"wp-image-98685\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-06.png 406w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/okta-aws-ebs-06-237x300.png 237w\" sizes=\"(max-width: 406px) 100vw, 406px\" \/><\/figure>\n<\/div>\n<p>If you supply your username and password, you are redirected to the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">\/<\/code>&nbsp;endpoint. In my case, I\u2019ll see the following message:<\/p>\n<pre class=\"gutter: false;brush:bash\">Hello, Daniel!\n<\/pre>\n<p>Now you have a secure web application! The best part: you didn\u2019t have to worry about implementing authentication yourself.<\/p>\n<h2 class=\"wp-block-heading\" id=\"redeploy-the-application-on-aws-elastic-beanstalk\">Redeploy the Application on AWS Elastic Beanstalk<\/h2>\n<p>You have a production-ready application, so let\u2019s send it to your production environment!&nbsp;<a href=\"https:\/\/console.aws.amazon.com\/\">Log in to the AWS Console<\/a>, and go to your&nbsp;<a href=\"https:\/\/us-east-1.console.aws.amazon.com\/elasticbeanstalk\/\">Elastic Beanstalk environment<\/a>.<\/p>\n<ul class=\"wp-block-list\">\n<li>Select the environment you created in the previous steps.<\/li>\n<li>In the menu, click on&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Configuration<\/code><\/li>\n<li>Press the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Modify<\/code>&nbsp;button inside the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Software<\/code>&nbsp;card.<\/li>\n<\/ul>\n<p>Add the same environment variables you used in your local environment:<\/p>\n<pre class=\"gutter: false;brush:bash\">OKTA_OAUTH2_ISSUER={ORG_URL}\/oauth2\/default\nOKTA_OAUTH2_CLIENT_ID={CLIENT_ID}\nOKTA_OAUTH2_CLIENT_SECRET={CLIENT_SECRET}\n<\/pre>\n<p>After making the changes click&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Apply<\/code>.<\/p>\n<p>The last step is to update the application to the latest version. Go inside your project folder, and type:<\/p>\n<pre class=\"gutter: false;brush:bash\">.\/mvnw package -DskipTests\n<\/pre>\n<p>This command generates a JAR file with the current version of your application. Go to the AWS Elastic Beanstalk dashboard, and click on the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Upload and deploy<\/code>&nbsp;button. Select the file aven created (such as&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">hello-word-0.0.1-SNAPSHOT.jar<\/code>), and click on the&nbsp;<code style=\"font-size:13px\" class=\"highlighter-rouge\">Deploy<\/code>&nbsp;button.<\/p>\n<p>To make sure it is working, click on the AWS Elastic Beanstalk URL. It will redirect you to the Okta\u2019s login if you haven\u2019t logged in. When you enter valid credentials, it will redirect you to the Hello World page! In my case, the result will be:<\/p>\n<pre class=\"gutter: false;brush:bash\">Hello, Daniel!\n<\/pre>\n<p>Congratulations! You have deployed an application in the cloud and handled security the right way.<\/p>\n<p>If you want to take a look at the code, you can find the repository with the examples&nbsp;<a href=\"https:\/\/github.com\/oktadeveloper\/spring-aws-elastic-beanstalk\">here<\/a>.<\/p>\n<p>Would you like to learn more about Security, OAuth 2.0, and Spring in general? We recommend these posts:<\/p>\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.okta.com\/blog\/2019\/05\/31\/spring-security-authentication?utm_campaign=text_website_all_multiple_dev_dev_spring-boot-aws-elastic_null&amp;utm_source=jcg&amp;utm_medium=cpc\">Simple Authentication with Spring Security<\/a><\/li>\n<li><a href=\"https:\/\/developer.okta.com\/blog\/2019\/05\/02\/spring-boot-single-sign-on-oauth-2?utm_campaign=text_website_all_multiple_dev_dev_spring-boot-aws-elastic_null&amp;utm_source=jcg&amp;utm_medium=cpc\">Easy Single Sign-On with Spring Boot and OAuth 2.0<\/a><\/li>\n<\/ul>\n<p>As always, leave comments below and don\u2019t forget to follow us on&nbsp;<a href=\"https:\/\/twitter.com\/oktadev\">Twitter<\/a>&nbsp;and subscribe to our&nbsp;<a href=\"https:\/\/www.youtube.com\/c\/oktadev\">YouTube<\/a>&nbsp;channel.<\/p>\n<p><a href=\"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk?utm_campaign=text_website_all_multiple_dev_dev_spring-boot-aws-elastic_null&amp;utm_source=jcg&amp;utm_medium=cpc\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">&#8220;Easy Spring Boot Deployment with AWS Elastic Beanstalk&#8221;<\/a>&nbsp;was originally published on the Okta Developer Blog on August 7, 2019. <\/p>\n<p><span style=\"font-size: 20px;\"><strong>Friends don\u2019t let friends write user auth. Tired of managing your own users?<\/strong><a href=\"https:\/\/developer.okta.com\/signup\/?utm_campaign=text_website_all_multiple_dev_dev_spring-boot-aws-elastic_null&amp;utm_source=jcg&amp;utm_medium=cpc\"> Try Okta\u2019s API and Java SDKs today. Authenticate, manage, and secure users in any application within minutes.<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Friends don\u2019t let friends write user auth. Tired of managing your own users? Try Okta\u2019s API and Java SDKs today. Authenticate, manage, and secure users in any application within minutes. Nearly all applications rely on authentication. Developers, and the companies that employ them, want to confirm who is making the request and are they who &hellip;<\/p>\n","protected":false},"author":103027,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[331,30,854],"class_list":["post-98679","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-amazon-aws","tag-spring","tag-spring-boot"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Easy Spring Boot Deployment with AWS Elastic Beanstalk - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about Spring Boot Deployment? Check our article explaining how to build a very simple \u201cHello World\u201d app in Spring Boot with OAuth 2.0\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Easy Spring Boot Deployment with AWS Elastic Beanstalk - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Spring Boot Deployment? Check our article explaining how to build a very simple \u201cHello World\u201d app in Spring Boot with OAuth 2.0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-30T06:35:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-10-14T09:47:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Daniel Pereira\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel Pereira\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/developer.okta.com\\\/blog\\\/2019\\\/08\\\/07\\\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/easy-spring-boot-deployment-aws-elastic-beanstalk.html\"},\"author\":{\"name\":\"Daniel Pereira\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/85e011dd160bc8513ac8d7e6184683a5\"},\"headline\":\"Easy Spring Boot Deployment with AWS Elastic Beanstalk\",\"datePublished\":\"2019-09-30T06:35:10+00:00\",\"dateModified\":\"2019-10-14T09:47:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/easy-spring-boot-deployment-aws-elastic-beanstalk.html\"},\"wordCount\":2403,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/developer.okta.com\\\/blog\\\/2019\\\/08\\\/07\\\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Amazon AWS\",\"Spring\",\"Spring Boot\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/developer.okta.com\\\/blog\\\/2019\\\/08\\\/07\\\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/09\\\/easy-spring-boot-deployment-aws-elastic-beanstalk.html\",\"url\":\"https:\\\/\\\/developer.okta.com\\\/blog\\\/2019\\\/08\\\/07\\\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk\",\"name\":\"Easy Spring Boot Deployment with AWS Elastic Beanstalk - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/developer.okta.com\\\/blog\\\/2019\\\/08\\\/07\\\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/developer.okta.com\\\/blog\\\/2019\\\/08\\\/07\\\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2019-09-30T06:35:10+00:00\",\"dateModified\":\"2019-10-14T09:47:49+00:00\",\"description\":\"Interested to learn about Spring Boot Deployment? Check our article explaining how to build a very simple \u201cHello World\u201d app in Spring Boot with OAuth 2.0\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/developer.okta.com\\\/blog\\\/2019\\\/08\\\/07\\\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/developer.okta.com\\\/blog\\\/2019\\\/08\\\/07\\\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/developer.okta.com\\\/blog\\\/2019\\\/08\\\/07\\\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/developer.okta.com\\\/blog\\\/2019\\\/08\\\/07\\\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Easy Spring Boot Deployment with AWS Elastic Beanstalk\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/85e011dd160bc8513ac8d7e6184683a5\",\"name\":\"Daniel Pereira\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f4d1b672347db86844a907a95b6b2c323b8d135c08f02c032383fb934269a174?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f4d1b672347db86844a907a95b6b2c323b8d135c08f02c032383fb934269a174?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f4d1b672347db86844a907a95b6b2c323b8d135c08f02c032383fb934269a174?s=96&d=mm&r=g\",\"caption\":\"Daniel Pereira\"},\"sameAs\":[\"https:\\\/\\\/developer.okta.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/daniel-pereira\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Easy Spring Boot Deployment with AWS Elastic Beanstalk - Java Code Geeks","description":"Interested to learn about Spring Boot Deployment? Check our article explaining how to build a very simple \u201cHello World\u201d app in Spring Boot with OAuth 2.0","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk","og_locale":"en_US","og_type":"article","og_title":"Easy Spring Boot Deployment with AWS Elastic Beanstalk - Java Code Geeks","og_description":"Interested to learn about Spring Boot Deployment? Check our article explaining how to build a very simple \u201cHello World\u201d app in Spring Boot with OAuth 2.0","og_url":"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2019-09-30T06:35:10+00:00","article_modified_time":"2019-10-14T09:47:49+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Daniel Pereira","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Daniel Pereira","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/easy-spring-boot-deployment-aws-elastic-beanstalk.html"},"author":{"name":"Daniel Pereira","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/85e011dd160bc8513ac8d7e6184683a5"},"headline":"Easy Spring Boot Deployment with AWS Elastic Beanstalk","datePublished":"2019-09-30T06:35:10+00:00","dateModified":"2019-10-14T09:47:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/easy-spring-boot-deployment-aws-elastic-beanstalk.html"},"wordCount":2403,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Amazon AWS","Spring","Spring Boot"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2019\/09\/easy-spring-boot-deployment-aws-elastic-beanstalk.html","url":"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk","name":"Easy Spring Boot Deployment with AWS Elastic Beanstalk - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#primaryimage"},"image":{"@id":"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2019-09-30T06:35:10+00:00","dateModified":"2019-10-14T09:47:49+00:00","description":"Interested to learn about Spring Boot Deployment? Check our article explaining how to build a very simple \u201cHello World\u201d app in Spring Boot with OAuth 2.0","breadcrumb":{"@id":"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/developer.okta.com\/blog\/2019\/08\/07\/deploy-a-spring-boot-app-with-aws-elastic-beanstalk#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Easy Spring Boot Deployment with AWS Elastic Beanstalk"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/85e011dd160bc8513ac8d7e6184683a5","name":"Daniel Pereira","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f4d1b672347db86844a907a95b6b2c323b8d135c08f02c032383fb934269a174?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f4d1b672347db86844a907a95b6b2c323b8d135c08f02c032383fb934269a174?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f4d1b672347db86844a907a95b6b2c323b8d135c08f02c032383fb934269a174?s=96&d=mm&r=g","caption":"Daniel Pereira"},"sameAs":["https:\/\/developer.okta.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/daniel-pereira"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/98679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/103027"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=98679"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/98679\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=98679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=98679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=98679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}