Web application environment configuration using maven profiles

Ok, this blog post will be short. I will just share some small maven code snippets to configure your build and development IDE environment.

For some projects there is a need to use specific environment properties, which may differ from deployment environment. Let's say in your IDE you use "Development" mode, however it is obvious that test, QA and production environments will use "Deployment" mode.

Usually such property is stored in web.xml file, for example:



  1. We do not want to commit "Development" mode into source control.
  2. We do not want to use "Deployment" mode in our local IDE.
  3. We do not want to have uncommitted changes if using "Development" mode locally.
  4. We DO want properly running local environment :) Sure!

By default property ${jsf.projectStage} is not properly understood by IDE (at least Eclipse WTP) and is not transformed into real value. Well, maybe it should be a nice feature... However, if you are using Apache Maven then this can be easily fixed.

Talks and documentation

  1. Introduction to Build Profiles
  2. Eclipse + maven : profile ignored
  3. And the solution is on stackoverflow described as well, however i could not find the link to it anymore when writing this blog :) I hope you will share this link with me :)


You need this environment setup in order to successfully complete the provided guide:


So far everything is about your pom.xml file configuration. You need to tell maven what resources should be filtered. Also tell maven which property file to use for resource filtering. And resolve this property file name dynamically using filter.name maven property.

    <!-- Add filter file name -->

        <!--  Define filtered resources -->

Then define different profiles you will need. And tell each profile which property file should be applied (<filter.name>production</filter.name>).


But we would like to have a default configuration for local environment. Let's define it in pom.xml as well.

    <!-- Default name of file for filtering -->


Now, eclipse IDE should automatically resolve and use default properties when you import maven project. For continuous delivery and console based builds you might be using such command:

mvn clean package -Pproduction

-P may be avoided if you want to use default properties, e.g. for development build.

Properties file location

Yes, you may define your own property files location based on your project structure:



Hopefully you did enjoy reading!


Senior software engineer, software architect for java enterprise based solutions