Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
492 views
Welcome To Ask or Share your Answers For Others

1 Answer

you can use:

@Autowired
private Environment env;

and then load property from code:

env.getProperty("your.property")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...