Reputation: 3128
I have the following property in my properties
test.property=context:test:sample
I'm trying to retrieve the value "test
" by doing a split with colon(:)
and getting the second part.
I'm doing this:
@Value("#{'${test.property}'.split(':')[1]}")
private String test;
However, it seems to come up as null
. Is there something wrong in what I'm doing? I have other properties being injected in the same file and they seem to be read without a problem. Even if I replace the expression above with just a @Value("${test.property}")
, it seems to read the string context:test:sample
Upvotes: 2
Views: 4794
Reputation: 174634
What you have works fine for me (I just tested it); you must have some other problem with your configuration. Turn on DEBUG logging for org.springframework
and watch all the injection processing.
Upvotes: 3