Dynamic Spring Configuration Files, Project Packaging, and Deployment Guide

This article explains how to use Spring's dynamic profile configuration to separate environment-specific YAML files, demonstrates jar and IDE launch options, outlines Maven and IDEA packaging steps, and provides detailed instructions for installing Java, configuring environment variables, and deploying the packaged Spring Boot application on a server.

Top Architect
Top Architect
Top Architect
Dynamic Spring Configuration Files, Project Packaging, and Deployment Guide

Dynamic Configuration Files

Spring allows specifying active profiles at startup to switch between environment‑specific configuration files such as application.yml, application-druid.yml, application-prod.yml, and application-druid-prod.yml. By copying the base files and renaming them, developers can avoid manual edits and reduce configuration errors.

Startup Methods

Jar launch with profile parameters: java -jar xxx.jar --spring.profiles.active=prod,druid-prod. Multiple profiles are separated by commas.

IDEA run configuration: edit the Spring Boot run configuration, set Active profiles to the desired profile suffixes (e.g., prod, druid-prod), and apply.

Project Packaging

The project consists of modules my-project-server, my-project-dependencies, and my-project-common. First install the dependency modules locally, then package the server module.

IDEA packaging: use the Maven lifecycle (clean, install, package) via the Maven tool window.

Maven command packaging: create a package.bat script that runs mvn install for the dependency modules and mvn clean package -Dmaven.test.skip=true for the server module.

Deployment

After building, the JAR appears in the target directory. Install Java (e.g., JDK 8) on the target server, set JAVA_HOME, JRE_HOME, CLASSPATH, and PATH in /etc/environment and /etc/profile, then source the profile.

Upload the JAR to a server directory (e.g., /usr/local/apps/my-project) and start it using one of the following commands:

Foreground: java -jar my-project-server-1.0.0-SNAPSHOT.jar Foreground with background: java -jar my-project-server-1.0.0-SNAPSHOT.jar & Background (recommended): nohup java -jar my-project-server-1.0.0-SNAPSHOT.jar & Access the running service via http://IP:8899/sys-user/get/all to verify the API.

Additional Notes

The article also contains promotional messages and links to related resources, but the core technical content focuses on Spring Boot backend configuration, packaging, and deployment.

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.

JavaDeploymentConfigurationmavenSpring 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.