Skip to content
Advertisement

Get all properties as map in properties file Spring Boot

I have a spring boot project , I want to get those properties as map by prefix , in this exemple the prefix is root :

application.properties :

JavaScript

I dont want to change my filetype from properties to YAML.

Advertisement

Answer

“Easy-peasy”:

JavaScript

With, application.properties:

JavaScript

And pom.xml:

JavaScript

… console prints:

JavaScript

To reside the properties in a “non-default location” (foo.properties e.g.), just:

JavaScript

..but attention: application.properties will have precedence!

Refs:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement