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

2
  • 2
    I would suggest to explain what do you want to achieve by specifying the bean name via property. Commented Aug 30, 2017 at 21:44
  • 1
    Check this answer: stackoverflow.com/questions/15328904/… TL;DR you cannot do it via annotations, but you could do it programatically Commented Aug 30, 2017 at 22:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.