java - Spring property value inside annotation -


how can property value inside annotation. example have annotation

@getmyvalue(value1="val1",intval=10) 

now want "val1" , 10 coming property file. tried

@getmyvalue(value1="${test.value}",intval="${test.int.value}") 

which doesn't work.

i understand can use

@value("${test.value}") string value;  @value("${test.int.value}") int intvalue; 

i don't want that, need inside annotation. suggestions?

in spring @value replacement of placeholder not done inside annotation framework when inspecting bean.

see

  • defaultlistablebeanfactory#doresolvedependency
  • defaultlistablebeanfactory#resolveembeddedvalue
  • org.springframework.util.stringvalueresolver

so, have "manually" annotation value1 , intval (which should string in annotation) , resolve them against properties file.


Comments