General Guide to Deploying a Spring Boot Microservice Project with Maven

This article provides a step‑by‑step tutorial on analyzing a Spring Boot microservice project, configuring parent and child Maven pom files, packaging modules with Maven plugins, and deploying both backend JARs and frontend assets to Windows or Linux servers.

Top Architect
Top Architect
Top Architect
General Guide to Deploying a Spring Boot Microservice Project with Maven

With the popularity of Spring Boot and Spring Cloud, many companies adopt microservice architectures; this article explains a generic deployment method for such projects.

1. Project Analysis

The example project contains modules business, file, gateway, generator, server, and system; only modules that have a main class (business, file, gateway, system) need to be packaged.

Below is the parent <project>... pom file, which defines the project structure, required plugins (maven-compiler-plugin, maven-surefire-plugin) and sets the packaging type to pom.

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.lsu</groupId>
    <artifactId>online-course</artifactId>
    <packaging>pom</packaging>
    <version>1.0.0</version>
    <modules>
        <module>system</module>
        <module>gateway</module>
        <module>server</module>
        <module>business</module>
        <module>generator</module>
        <module>file</module>
    </modules>
    ...
</project>

2. Packaging the Project

2.1 Parent pom

Specify maven-compiler-plugin and maven-surefire-plugin in the <build><plugins> section.

Set <packaging>pom</packaging> for the parent project.

2.2 Child pom (example: business module)

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <parent>
        <artifactId>online-course</artifactId>
        <groupId>com.lsu</groupId>
        <version>1.0.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <packaging>jar</packaging>
    <artifactId>business</artifactId>
    ...
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.lsu.business.BusinessMainApplication</mainClass>
                    <layout>ZIP</layout>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Specify spring-boot-maven-plugin and the fully‑qualified main class.

Set <packaging>jar</packaging> for the module.

2.3 Execute packaging

Run mvn package (via IDEA’s Maven plugin or command line). The built JAR files appear in each module’s target directory.

Start a service with java -jar business-1.0.0.jar.

3. Deploy the Project

Copy the JARs to a Windows Server 2012 or Linux host that already has Java installed, then launch them with the java -jar command.

For the front‑end, use a multi‑environment configuration (e.g., .env.dev) and run the build script defined in package.json with the --mode dev flag. The build generates a dist directory which can be served by http-server or Nginx.

Additional notes: install http-server globally via cnpm install http-server -g, then execute it inside the dist folder to view the application.

The remainder of the source contains promotional messages for a ChatGPT community, giveaway links, and various unrelated article recommendations, which are not part of the technical guide.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendfrontendMicroservicesDeploymentmavenSpring Boot
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.