kaido
kaido

Reputation: 351

where does spring look for values with the @Value annotation

In java/spring, when you use the @Value annotation to insert values into a field, where exactly does the application look for these values? I have read up and I keep seeing that it looks for a "properties file" but is there a specific name/format this file needs to have, or a certain directory this file needs to be in?

Upvotes: 0

Views: 1657

Answers (1)

Birju B
Birju B

Reputation: 140

If you don't give any specific path thn it will use default path :

\src\main\resources\application.properties

You can also give specific path :

@propertySource("file:properties/application.properties")

Here properties folder is on same level of src folder. You can put your property file anywhere.

Hope this will work!

Upvotes: 1

Related Questions