Maven: how to compile project with input parameters

1.5k views Asked by At

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

1

There are 1 answers

0
Cuzz On

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.