Maven Profiles: Detailed Explanation

Anish Antony
Javarevisited
Published in
3 min readDec 24, 2020

--

Maven is so much portable and customizable. You can customize your maven build based on the user, environment, server …etc. with the help of profiles. Based on profile values it can able to override the default maven build behaviour. Over this article, let's see how to make a maven profile and how to customize the build based on profile values.

Photo by Austin Distel on Unsplash

The profile is a great feature on Maven. Using profile it is able to customize the build for different environments. The maven build can be deployed on different environments say staging, development, production…etc. Based on each environment the build configuration may differ.

Say example in a development build it is using the development database configuration, it may not compress the javascript files and the build is compatible with web servers.

But comes to production configuration, the build is using prod database, it will compress the js and CSS, core data are encrypted, and the build is for application servers. Using profile these all can manage

The basic idea behind the Profile is, the profile comes with an alternative configuration that will override the default configuration. So if you make the maven build with a profile, then it will override the default configuration with the profile configuration

How to create a profile…

--

--

Anish Antony
Javarevisited

Fullstack Developer | Blogger | Experience on Java, Python, React, Angular, Golang | http://www.behindjava.com