Harshana
Harshana

Reputation: 7647

Read property values in Spring Boot

How can I read the properties in a property file inside a Spring boot application?

In a normal Spring application we can do this by adding this in context:

<context:property-placeholder location="classpath*:my.properties"/>

Then refer the property using:

@Value("${my.property.name}")
Private String name;

Upvotes: 0

Views: 353

Answers (1)

Avis
Avis

Reputation: 2237

Just use @SpringBootApplication and your @Value will pick value from application.properties or yml from resource folder.

Upvotes: 1

Related Questions