I have following property in my application.properties file.
test.product.release.version=2003.1
test.product.release.year=#{'${test.product.release.version}'.split('[.]')[0]
When I use the property test.product.release.year
in my spring controller using @Value
annotation, it's giving me value as 2003, but when I get the value of it through AbstractEnvironment#getProperty
I am getting value as
#{'${test.product.release.version}'.split('[.]')[0]
How can I get the value 2003 by using AbstractEnvironment?
No you can not use SpEL within properties files.
You can however use placeholders within properties files, eg:
app.name=MyApp
app.description=${app.name} is a Spring Boot application
For your use case, you should look at the profile-specific configuration mechanism.
Which allows you to load different config based on an environment profile.