Reading properties with dynamic keys in spring boot

I wanted to know if there is a way in Spring Boot to read property values ​​from a property file using Dynamic Keys. I know that properties can be placed in application.propertiesand can be read using. @Value("propertyKey")But my keys will be dynamic.

I know about @PropertySourceto read property values, and I can dynamically build my keys. So, is there a way that Spring Boot is provided?

+4
source share
1 answer

you can use:

@Autowired
private Environment env;

and then load the property from the code:

env.getProperty("your.property")
+11
source

Source: https://habr.com/ru/post/1653084/


All Articles