Reputation: 1152
I'm trying to access the version of my system (defined into pom.xml) from a JSP. It's the login screen, so no action was called before.
Is there a way to Spring read the version number from my pom and put it into request / session?
Thanks a lot for the attention!
Upvotes: 0
Views: 2916
Reputation: 279960
You can perform resource filtering with Maven. Given the following in pom.xml
<properties>
<system.version>1.2.3.4</system.version>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
any file in src/main/resources
with a placeholder ${some.property}
, where some.property
resolves to a property in the pom.xml
, will be replaced by the value of that property. For example, if you had a property file globals.properties
like
system.version=${system.version}
Maven would filter the file and change it to
system.version=1.2.3.4
You can then have Spring inject that property with a PropertySourcesPlaceholderConfigurer
and @Value
.
Upvotes: 5