use @value in non-bean class in spring boot

699 Views Asked by At

I am working on spring boot project.I create a singleton class in my spring boot application.I wanna get properties from application.properties in my singleton class.is it possible in non-bean class?How to do?

1

There are 1 best solutions below

1
luboskrnac On BEST ANSWER

Every Spring bean is singleton scope by default. Therefore you should not use Java singleton class pattern in Spring driven application, just use spring bean and inject @Value there.