Maven : Include different properties files based on profile

This page last changed on Oct 06, 2007 by Kees de Kooter

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