Retrive value from yaml file to field in external library



I have a Spring Boot application
I have a external library (written by me, also using Spring parent) as dependency

In application.yml (in application, not in library) I have property example

In library, I have a class with code like this:

@Value("${example}")
private String example;

The value for this field is null, but when I’m calling for Environmet this value is accessible. Any hint what should I do to get value by using @Value?

Answer

May be you forget add @Component annotation your class



Source: stackoverflow