Read properties by dynamic keys in spring boot

2020-02-28 06:17发布

I wanted to know if there is any way in Spring Boot to read property values from properties file by using Dynamic Keys. I know properties can be put in application.properties and can be read using @Value("propertyKey") But my keys are going to be dynamic.

I know about @PropertySource to read property values and I can construct my keys dynamically. So is there any way that is provided by Spring Boot?

1条回答
唯我独甜
2楼-- · 2020-02-28 07:07

you can use:

@Autowired
private Environment env;

and then load property from code:

env.getProperty("your.property")
查看更多
登录 后发表回答