Imagine there is a class:
@Something(someProperty = \"some value\")
public class Foobar {
//...
}
Which is already compiled (I cannot c
SPRING can do this job very easily , might be useful for spring developer . follow these steps :-
First Solution :- 1)create a Bean returning a value for someProperty . Here I injected the somePropertyValue with @Value annotation from DB or property file :-
@Value("${config.somePropertyValue}")
private String somePropertyValue;
@Bean
public String somePropertyValue(){
return somePropertyValue;
}
2)After this , it is possible to inject the somePropertyValue into the @Something annotation like this :-
@Something(someProperty = "#{@somePropertyValue}")
public class Foobar {
//...
}
Second solution :-
1) create getter setter in bean :-
@Component
public class config{
@Value("${config.somePropertyValue}")
private String somePropertyValue;
public String getSomePropertyValue() {
return somePropertyValue;
}
public void setSomePropertyValue(String somePropertyValue) {
this.somePropertyValue = somePropertyValue;
}
}
2)After this , it is possible to inject the somePropertyValue into the @Something annotation like this :-
@Something(someProperty = "#{config.somePropertyValue}")
public class Foobar {
//...
}