5

I have one property file called environment.properties. In this file I have one entry:

applicationUrl = ${applicationUrlFromPom}

I want to use maven resource plugin setting in pom file, so that this value could be set at build time and I can use this value from properties file in Java.

thnx in advance

Code Painters
  • 7,175
  • 2
  • 31
  • 47
sumit
  • 189
  • 3
  • 11

1 Answers1

6

Assuming you have properties in your pom as

<properties>
   <applicationUrlFromPom>http://www.coolbeans.com/some/url</applicationUrlFromPom>
</properties>

You need to add resource filtering

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
    </resource>
</resources>

where the <directory> is the directory your properties file is in.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
  • Hi Sotirios, Thnx for your reply. i have done what u have suggested, but its not replacing the value of "applicationUrlFromPom" from POM to properties file. Any suggestion why? – sumit Sep 18 '13 at 07:16
  • @sumit Have you run `mvn clean install`? Is the property name the same in your pom as it is in your properties file? IS the properties file in the specified directory? Don't look at your source, look at the built target. – Sotirios Delimanolis Sep 18 '13 at 12:29
  • Yes its there. thnx once again. – sumit Sep 18 '13 at 13:14