Reputation: 1664
I have some properties in my maven pom.xml.
<properties>
<number>3</number>
<age>38</age>
</properties>
(They are random properties)
In a properties file, lets call it resource.properties, I have the following:
value1 = ${number}
value2 = ${age}
When spring tries to read properties from this file, it cannot get the reference from ${number}
saying that it cannot be found.
Why is this and how can I make it work? Or is doing this not possible at all.
EDIT: I have enabled filtering but still does not work. My resource is in the src/test/resources
directory.
Here is the part of the pom where I enable filtering.
<build>
...
<resources>
<resource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
...
</build>
Upvotes: 0
Views: 626
Reputation: 6204
You should enable resource filtering for the maven resources plugin as shown below:
...
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
...
See the Maven Resources Plugin section about filtering for details.
Upvotes: 1
Reputation: 6630
you need to tell maven which files it uses to replace placeholders e.g
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
see maven filter
Upvotes: 2