0

I would like to do something like that following

@Service("${application.property}")
public class SampleClass {

similar to how we see for Value annotation

@Value("${application.property}") 
private String field;

The "${application.property}" would be taken from the application.properties file. I feel like this should be possible as the application.properties file is in memory. I have searched however and cannot find a solution. Maybe there is some secret annotation or other configuration to achieve this? Any help is appreciated

dinamix
  • 651
  • 8
  • 22
  • 2
    I would suggest to explain what do you want to achieve by specifying the bean name via property. – Alexander Aug 30 '17 at 21:44
  • 1
    Check this answer: https://stackoverflow.com/questions/15328904/dynamically-declare-beans-at-runtime-in-spring TL;DR you cannot do it via annotations, but you could do it programatically – diginoise Aug 30 '17 at 22:02

0 Answers0