1

I compile my project like this:

mvn clean install

But my project has the different parameters for another servers and I need to fix it after compilation (for example location=prod on production server and location=dev on local server) I have a pice of code in my web.xml like this:

<init-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>
          classpath:/properties-config.xml
     </param-value>
</init-param>

I want to use the variable location like this :

classpath:/${location}/properties-config.xml

eebbesen
  • 5,070
  • 8
  • 48
  • 70
Oleg
  • 11
  • 4
  • possible duplicate of [How to pass parameters to maven build using pom.xml?](http://stackoverflow.com/questions/24206013/how-to-pass-parameters-to-maven-build-using-pom-xml) – kamoor Dec 24 '14 at 14:07
  • 2
    Another / our approach is: We start all our servers with a specific vm argument (the.environment=production/test/integration/etc) and in our applications, we load our configurations from /our/resource/package/-current-environment/configuration.properties. So one build will run on all servers. – slowy Dec 24 '14 at 14:10
  • 1
    Maven filtering (as suggested in [krmanish007's answer](http://stackoverflow.com/a/27638282/3127111)) + POM properties is the way to go. – watery Dec 26 '14 at 10:10

1 Answers1

1

Try to pass it like a VM argument: -Dargument=value

so run maven will be: mvn clean install -Dlocation=dev

it works for me, but not in web-xml. Hope this will help u.

Cuzz
  • 428
  • 2
  • 4
  • 20