In a springboot application, how can I read values form application.yml, if I need to use them in my code

Following is my application.yml file –

    port: 587

In one of my Java classes, I want to use the port number, which annotation I can use to achieve the same.

>Solution :

You can use the @Value annotation:

private Integer port;

Leave a Reply