Include different properties files based on profile in Maven

author's avatar
Kees de Kooter
Jun 4 9:52 • 1 min read

The following solutions enables you to package your project for different environments, like develop / test / staging / live.

The profile definition:


In the project you create a subdirectory in src/main/profiles for every profile. In that subdir you can put configuration files that are specific for the targeted environment. Mine usually contain a log4j.xml and a that my Spring configuration uses (for more on this see Use PropertyOverrrideConfigurer to target different deployment environments).

Next we add resources to the build. Note the ${} parameter.


To use a specific profile in maven you use the -P parameter:

mvn package -Pdevelop