<?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: Amit Salvi</title>
    <description>The latest articles on DEV Community by Amit Salvi (@amit_salvi_at_dev_to).</description>
    <link>https://dev.to/amit_salvi_at_dev_to</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%2F3256694%2F83178fe8-dc76-4d67-aaf5-daad72b05901.jpg</url>
      <title>DEV Community: Amit Salvi</title>
      <link>https://dev.to/amit_salvi_at_dev_to</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amit_salvi_at_dev_to"/>
    <language>en</language>
    <item>
      <title>Create a Java Microservice Using Spring Boot in Minutes with Maven</title>
      <dc:creator>Amit Salvi</dc:creator>
      <pubDate>Tue, 10 Jun 2025 21:16:19 +0000</pubDate>
      <link>https://dev.to/amit_salvi_at_dev_to/create-a-java-microservice-using-spring-boot-in-minutes-with-maven-50p9</link>
      <guid>https://dev.to/amit_salvi_at_dev_to/create-a-java-microservice-using-spring-boot-in-minutes-with-maven-50p9</guid>
      <description>&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;p&gt;In this post, we'll create a minimal Java microservice using Spring Boot and Maven. We'll use Maven's archetype to bootstrap our project and add a simple REST endpoint using the embedded Tomcat server that comes with Spring Boot.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Generate Project Using Maven
&lt;/h2&gt;

&lt;p&gt;You can use Spring Boot's official &lt;a href="https://github.com/spring-projects/spring-boot/tree/main/spring-boot-project/spring-boot-archetypes" rel="noopener noreferrer"&gt;archetype&lt;/a&gt; or simply use the spring-boot-starter-parent and manually add dependencies.&lt;/p&gt;

&lt;p&gt;Option 1: Use Maven Archetype (Manually Add Dependencies)&lt;br&gt;
There’s no built-in official archetype for Spring Boot like there is for other frameworks, but you can generate a skeleton project like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mvn archetype:generate \&lt;br&gt;
  -DgroupId=com.example.micro \&lt;br&gt;
  -DartifactId=simple-microservice \&lt;br&gt;
  -DarchetypeArtifactId=maven-archetype-quickstart \&lt;br&gt;
  -DinteractiveMode=false&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then, modify the pom.xml to convert it into a Spring Boot project&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Update pom.xml for Spring Boot
&lt;/h2&gt;

&lt;p&gt;Replace the contents of pom.xml with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
         http://maven.apache.org/xsd/maven-4.0.0.xsd"&amp;gt;
  &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;

  &amp;lt;groupId&amp;gt;com.example.micro&amp;lt;/groupId&amp;gt;
  &amp;lt;artifactId&amp;gt;simple-microservice&amp;lt;/artifactId&amp;gt;
  &amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;
  &amp;lt;packaging&amp;gt;jar&amp;lt;/packaging&amp;gt;

  &amp;lt;parent&amp;gt;
    &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;spring-boot-starter-parent&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;3.2.2&amp;lt;/version&amp;gt;
    &amp;lt;relativePath/&amp;gt; &amp;lt;!-- lookup parent from repository --&amp;gt;
  &amp;lt;/parent&amp;gt;

  &amp;lt;dependencies&amp;gt;
    &amp;lt;!-- Web starter includes embedded Tomcat --&amp;gt;
    &amp;lt;dependency&amp;gt;
      &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
      &amp;lt;artifactId&amp;gt;spring-boot-starter-web&amp;lt;/artifactId&amp;gt;
    &amp;lt;/dependency&amp;gt;
    &amp;lt;dependency&amp;gt;
      &amp;lt;groupId&amp;gt;junit&amp;lt;/groupId&amp;gt;
      &amp;lt;artifactId&amp;gt;junit&amp;lt;/artifactId&amp;gt;
      &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
    &amp;lt;/dependency&amp;gt;
  &amp;lt;/dependencies&amp;gt;

  &amp;lt;build&amp;gt;
    &amp;lt;plugins&amp;gt;
      &amp;lt;plugin&amp;gt;
        &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;spring-boot-maven-plugin&amp;lt;/artifactId&amp;gt;
      &amp;lt;/plugin&amp;gt;
    &amp;lt;/plugins&amp;gt;
  &amp;lt;/build&amp;gt;

&amp;lt;/project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Create Main Application Class
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.micro;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SimpleMicroserviceApplication {
    public static void main(String[] args) {
        SpringApplication.run(SimpleMicroserviceApplication.class, args);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Add a REST Controller
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.micro.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @GetMapping("/hello")
    public String hello() {
        return "Hello from Spring Boot Microservice!";
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Run the Application
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mvn spring-boot:run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. Wrap-up
&lt;/h2&gt;

&lt;p&gt;And that’s it! You now have a working microservice with a REST endpoint running on embedded Tomcat, created entirely from the command line using Maven.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
