<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: EI Akoji</title>
    <description>The latest articles on DEV Community by EI Akoji (@akojimsg).</description>
    <link>https://dev.to/akojimsg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F72936%2F38ae02c5-0b15-44ba-a37c-16622f925754.jpeg</url>
      <title>DEV Community: EI Akoji</title>
      <link>https://dev.to/akojimsg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akojimsg"/>
    <language>en</language>
    <item>
      <title>Use CLI to generate your spring starter projects</title>
      <dc:creator>EI Akoji</dc:creator>
      <pubDate>Wed, 17 Apr 2024 04:13:53 +0000</pubDate>
      <link>https://dev.to/akojimsg/use-cli-to-generate-your-spring-template-32fh</link>
      <guid>https://dev.to/akojimsg/use-cli-to-generate-your-spring-template-32fh</guid>
      <description>&lt;p&gt;In the world of Spring Boot development, starting a new project with spring.io, manually downloading and extracting the starter-template can be cumbersome. Fortunately, Spring CLI (Command Line Interface) provides a convenient solution to streamline this process. In this article, we'll explore how to leverage Spring CLI to generate a Spring Boot project template quickly and efficiently.&lt;/p&gt;

&lt;p&gt;Spring CLI allows you to quickly bootstrap and develop Spring-based applications using Groovy scripts. Here's a step-by-step guide to create a new project:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Install Spring CLI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you haven't installed Spring CLI yet, you can download it from the official Spring website or use SDKMAN! (The Software Development Kit Manager). Here's how to install it using SDKMAN!:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   sdk &lt;span class="nb"&gt;install &lt;/span&gt;springboot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command installs the Spring Boot CLI along with the Spring CLI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Create a New Project&lt;/strong&gt;&lt;br&gt;
Once you have Spring CLI installed, you can create a new project using the &lt;code&gt;spring init&lt;/code&gt; command followed by the project name and the dependencies you want to include. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   spring init &lt;span class="nt"&gt;--dependencies&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;web,data-jpa my-spring-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates a new Spring Boot project named &lt;code&gt;my-spring-project&lt;/code&gt; with web and data JPA dependencies. You can obtain detailed information on the different options available to use with the spring init command viz:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Customize Project Settings:&lt;/strong&gt;&lt;br&gt;
You can customize your project settings by specifying additional options in the &lt;code&gt;spring init&lt;/code&gt; command. For instance, you can specify the project's language, build system, and packaging format. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   spring init &lt;span class="nt"&gt;--java-version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;21 &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--build&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gradle &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--packaging&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;jar &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;gradle-project &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--artifact-id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;demo &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--group-id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;com.example &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--dependencies&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;actuator,data-jdbc,postgresql,web &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--extract&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
   my-spring-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates a new Spring Boot project with Java 21, Gradle as the build system, JAR packaging with actuator, data-jdbc, postgresql, web as dependencies. To view more customizable options, do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   sdk &lt;span class="nt"&gt;--help&lt;/span&gt; init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;--dependencies, -d &lt;/td&gt;
&lt;td&gt;Comma-separated list of dependencies to include&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--version, -v &lt;/td&gt;
&lt;td&gt;Version of Spring Boot to use (e.g., 2.6.0, 2.5.4.RELEASE)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--build, -b &lt;/td&gt;
&lt;td&gt;Build tool to use (maven or gradle)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--java, -j &lt;/td&gt;
&lt;td&gt;Java version (e.g., 1.8, 11, 17)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--language, -l &lt;/td&gt;
&lt;td&gt;Language for the project (java, groovy, kotlin)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--package-name, -p &lt;/td&gt;
&lt;td&gt;Base package name for the project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--groupId, -g &lt;/td&gt;
&lt;td&gt;Group ID for the project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--artifactId, -a &lt;/td&gt;
&lt;td&gt;Artifact ID for the project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--boot-version &lt;/td&gt;
&lt;td&gt;Version of Spring Boot to use&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--force, -f&lt;/td&gt;
&lt;td&gt;Overwrite any existing files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--extract, -x &lt;/td&gt;
&lt;td&gt;Extracts the given archive to the project directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--list, -ls&lt;/td&gt;
&lt;td&gt;List all available Spring Boot versions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--list-modules, -lm &lt;/td&gt;
&lt;td&gt;List the modules for a given version&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--list-templates, -lt&lt;/td&gt;
&lt;td&gt;List all available project templates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--no-overwrite&lt;/td&gt;
&lt;td&gt;Skips writing files if they already exist&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--packaging, -P &lt;/td&gt;
&lt;td&gt;Packaging to use for the project (e.g., jar, war)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--name, -n &lt;/td&gt;
&lt;td&gt;Project name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--description, -d &lt;/td&gt;
&lt;td&gt;Project description&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--force, -f&lt;/td&gt;
&lt;td&gt;Overwrite existing files without prompting&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--format, -of &lt;/td&gt;
&lt;td&gt;Format the output using the given format (e.g., json, yaml)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--list, -ls&lt;/td&gt;
&lt;td&gt;List all available versions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--list-boot, -lb &lt;/td&gt;
&lt;td&gt;List all available Spring Boot versions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--list-all&lt;/td&gt;
&lt;td&gt;List all available Spring Boot versions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--list-templates, -lt&lt;/td&gt;
&lt;td&gt;List all available project templates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--yes, -y&lt;/td&gt;
&lt;td&gt;Always use the default value for prompts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--no-color, -nc&lt;/td&gt;
&lt;td&gt;Disable color output&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--quiet, -q&lt;/td&gt;
&lt;td&gt;Quiet output mode (no progress bar)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--stacktrace, -st&lt;/td&gt;
&lt;td&gt;Print stack trace on application failure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--version, -v&lt;/td&gt;
&lt;td&gt;Print the version number&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--help, -h&lt;/td&gt;
&lt;td&gt;Print this help message&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This table summarizes the options available for the &lt;code&gt;spring init&lt;/code&gt; command, along with their descriptions. You can use these options to customize the generation of your Spring Boot project according to your requirements. Here are some examples:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To list all the capabilities of the service:
    $ spring init --list

To creates a default project:
    $ spring init

To create a web my-app.zip:
    $ spring init -d=web my-app.zip

To create a web/data-jpa gradle project unpacked:
    $ spring init -d=web,jpa --build=gradle my-dir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Available Spring Initializr Dependencies/Templates&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dependencies:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;actuator&lt;/code&gt;: Actuator: Production-ready features to help you monitor and manage your application&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;batch&lt;/code&gt;: Batch: Support for Spring Batch including HSQLDB database&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data-cassandra&lt;/code&gt;: Spring Data Cassandra: Apache Cassandra database support&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data-jdbc&lt;/code&gt;: Spring Data JDBC: Simplified database access via JDBC&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data-jpa&lt;/code&gt;: Spring Data JPA: Simplified database access via JPA&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data-ldap&lt;/code&gt;: Spring Data LDAP: Simplified LDAP access&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data-mongodb&lt;/code&gt;: Spring Data MongoDB: MongoDB database support&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data-rest&lt;/code&gt;: Spring Data REST: Expose Spring Data repositories over REST via Spring Data REST&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data-solr&lt;/code&gt;: Spring Data Solr: Apache Solr search platform support&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;jersey&lt;/code&gt;: Jersey: RESTful Web Services with JAX-RS and Jersey&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;jms&lt;/code&gt;: JMS: Java Messaging Service&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;jmx&lt;/code&gt;: JMX: Java Management Extensions&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mail&lt;/code&gt;: Mail: Sending email using Spring Framework's email abstraction&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mobile&lt;/code&gt;: Mobile: Support for mobile web applications with jQuery Mobile&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mqtt&lt;/code&gt;: MQTT: MQTT support&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;security&lt;/code&gt;: Security: Authentication and Authorization with Spring Security&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;thymeleaf&lt;/code&gt;: Thymeleaf: Thymeleaf engine&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;web&lt;/code&gt;: Web: Full-stack web development with Tomcat and Spring MVC&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;websocket&lt;/code&gt;: WebSocket: WebSocket support&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Templates:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;activiti&lt;/code&gt;: Activiti: Business Process Modeling&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;batch&lt;/code&gt;: Batch Service&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cloud-config-client&lt;/code&gt;: Config Client: Distributed Versioned Configuration&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cloud-config-server&lt;/code&gt;: Config Server: Centralized External Configuration Management&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cloud-eureka&lt;/code&gt;: Eureka Discovery: Service Registration and Discovery&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cloud-gateway&lt;/code&gt;: Gateway: API Gateway&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cloud-hystrix&lt;/code&gt;: Hystrix: Circuit Breaker&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cloud-zuul&lt;/code&gt;: Zuul: API Gateway&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kafka&lt;/code&gt;: Apache Kafka: Kafka Support&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kotlin&lt;/code&gt;: Kotlin: Kotlin Programming Language Support&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mongodb&lt;/code&gt;: MongoDB: MongoDB Support&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;restdocs&lt;/code&gt;: Spring REST Docs: Documentation generation for RESTful services&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;security-oauth2&lt;/code&gt;: OAuth2: OAuth 2.0 Support&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;webflux&lt;/code&gt;: WebFlux: Reactive Web Support&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Project types (* denotes the default)&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Id&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Tags&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;gradle-build&lt;/td&gt;
&lt;td&gt;Generate a Gradle build file.&lt;/td&gt;
&lt;td&gt;build:gradle,format:build&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;gradle-project *&lt;/td&gt;
&lt;td&gt;Generate a Gradle based project archive using the Groovy DSL.&lt;/td&gt;
&lt;td&gt;build:gradle,dialect:groovy,format:project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;gradle-project-kotlin&lt;/td&gt;
&lt;td&gt;Generate a Gradle based project archive using the Kotlin DSL.&lt;/td&gt;
&lt;td&gt;build:gradle,dialect:kotlin,format:project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;maven-build&lt;/td&gt;
&lt;td&gt;Generate a Maven pom.xml.&lt;/td&gt;
&lt;td&gt;build:maven,format:build&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;maven-project&lt;/td&gt;
&lt;td&gt;Generate a Maven based project archive.&lt;/td&gt;
&lt;td&gt;build:maven,format:project&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Id&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Default value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;artifactId&lt;/td&gt;
&lt;td&gt;project coordinates (infer archive name)&lt;/td&gt;
&lt;td&gt;demo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bootVersion&lt;/td&gt;
&lt;td&gt;spring boot version&lt;/td&gt;
&lt;td&gt;3.2.4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;description&lt;/td&gt;
&lt;td&gt;project description&lt;/td&gt;
&lt;td&gt;Demo project for Spring Boot&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;groupId&lt;/td&gt;
&lt;td&gt;project coordinates&lt;/td&gt;
&lt;td&gt;com.example&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;javaVersion&lt;/td&gt;
&lt;td&gt;language level&lt;/td&gt;
&lt;td&gt;17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;language&lt;/td&gt;
&lt;td&gt;programming language&lt;/td&gt;
&lt;td&gt;java&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;name&lt;/td&gt;
&lt;td&gt;project name (infer application name)&lt;/td&gt;
&lt;td&gt;demo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;packageName&lt;/td&gt;
&lt;td&gt;root package&lt;/td&gt;
&lt;td&gt;com.example.demo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;packaging&lt;/td&gt;
&lt;td&gt;project packaging&lt;/td&gt;
&lt;td&gt;jar&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;type&lt;/td&gt;
&lt;td&gt;project type&lt;/td&gt;
&lt;td&gt;gradle-project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;version&lt;/td&gt;
&lt;td&gt;project version&lt;/td&gt;
&lt;td&gt;0.0.1-SNAPSHOT&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Navigate to the Project Directory&lt;/strong&gt;&lt;br&gt;
Once the project is created, navigate to the project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;cd &lt;/span&gt;my-spring-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Open the Project in Your Preferred IDE:&lt;/strong&gt;&lt;br&gt;
Open the project in your favorite Integrated Development Environment (IDE) such as IntelliJ IDEA, Eclipse, or Visual Studio Code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Start Developing:&lt;/strong&gt;&lt;br&gt;
You can now start developing your Spring application. The project structure is set up with a basic application class and directory structure, allowing you to add your own controllers, services, repositories, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7: Run Your Application:&lt;/strong&gt;&lt;br&gt;
To run your Spring Boot application, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   ./mvnw spring-boot:run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're using Gradle, you can run your application with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   ./gradlew bootRun
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your Spring Boot application will start, and you can access it at &lt;code&gt;http://localhost:8080&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That's it! You've successfully created a new Spring Boot project using Spring CLI and can now start building your application.&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>springcli</category>
    </item>
    <item>
      <title>Run Springboot application with Elastic Beanstalk, SSH and EC2</title>
      <dc:creator>EI Akoji</dc:creator>
      <pubDate>Sun, 17 Mar 2024 08:04:24 +0000</pubDate>
      <link>https://dev.to/akojimsg/run-springboot-application-with-elastic-beanstalk-ssh-and-ec2-5gk0</link>
      <guid>https://dev.to/akojimsg/run-springboot-application-with-elastic-beanstalk-ssh-and-ec2-5gk0</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl99gbdrza8psq4r01r4j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl99gbdrza8psq4r01r4j.png" alt="Image description" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recently, I worked on a PoC to create an automated build pipeline for a springboot rest api in elastic beanstalk. Based on prior knowledge related to the use of Amazon EBS, this was expected to be a trivial tasks. Turns out that without a solid knowledge on setting up and managing configurations for AWS resources, doing this can be challenging.&lt;/p&gt;

&lt;p&gt;There are a host of pages and videos explaining how to deploy spring/springboot applications to elastic beanstalk. however, I was not lucky enough to find one explaining details of the underlying computing resource for this configuration.&lt;/p&gt;

&lt;p&gt;For this post, I am focusing on the configuration required to deploy a java application on elastic bean stalk, using Amazon EBS CLI. This can also be done with AWSCLI, though, EBS CLI is tailored to meet our needs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Infrastructure Diagram
&lt;/h3&gt;

&lt;p&gt;To run java applications with EBS, we can use several configurations. Deploying an application that runs on scalable EC2 instances is common, hence is used in this guide. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg5ly6ehe2c6fsxdd8iph.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg5ly6ehe2c6fsxdd8iph.png" alt="illustration of AWS EBS with EC2 environments" width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Requirements
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You'll obviously need to have an AWS account with the required access level to AWS console.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you have not done so, &lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html"&gt;install AWSCLI&lt;/a&gt; and &lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html"&gt;configure your credentials&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can create named profiles with your aws credentials and configuration &lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html"&gt;using this guide&lt;/a&gt;. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Install &lt;a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html"&gt;EBS CLI&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Follow &lt;a href="https://www.baeldung.com/spring-boot-deploy-aws-beanstalk"&gt;this tutorial&lt;/a&gt; to create and deploy a simple springboot application with AWS Elastic Beanstalk. Remember to select "create a new SSH public, private key pair" when prompted to.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Implementation Notes
&lt;/h3&gt;

&lt;p&gt;I noticed that the &lt;code&gt;eb create&lt;/code&gt; command fails when the following line is added:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deploy:
  artifact: target/spring-boot-bootstrap-eb.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you get the following error message: &lt;em&gt;ERROR: NotFoundError - Application Version does not exist locally (target/spring-boot-bootstrap-eb.jar). Try uploading the Application Version again.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Remove the deploy artifact configuration and use the following command to create your environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ eb create --source target/spring-boot-bootstrap-eb.jar --$ version spring-boot-bootstrap-eb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly run the following command to deploy&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ eb deploy --version spring-boot-bootstrap-eb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can review the &lt;a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-cmd-commands.html"&gt;CLI documentation&lt;/a&gt; or use &lt;code&gt;eb command_name --help&lt;/code&gt; to view usage of different commands.&lt;/p&gt;

&lt;h3&gt;
  
  
  SSH to your EC2 Instance
&lt;/h3&gt;

&lt;p&gt;Now you're all set to go!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ eb ssh
$ cd /var/app/current
$ java -jar application.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run regular commands as you'd do in a local environment. This can be useful for troubleshooting application instances.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>elasticbeanstalk</category>
      <category>springboot</category>
    </item>
  </channel>
</rss>
