In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the springboot application.properties file injection array mode". In the daily operation, I believe that many people have doubts about the springboot application.properties file injection array mode. The editor consulted all kinds of information and sorted out a simple and easy-to-use operation method. I hope it will be helpful to answer the question of "what is the springboot application.properties file injection array way?" Next, please follow the editor to study!
Application.properties file injection array
1.application.properties
Ips=192.168.0.105192.168.0.106,0:0:0:0:0:0:0:1
two。 Code
@ Value ("# {${ips} '.split (',')}") private List iplist; injects value,list and map configuration files into application.properties
Configure the values that need to be injected in the configuration file.
# single value val=10#Listlist=1,2,3,4#Mapmap= {'name':'chen',' age':'12', 'sex':' male'} # Mapmap.of.list= {\ 'KEY1': {' value1','value2'},\ 'KEY2': {' value3','value4'},\ 'KEY3': {' value5'}\} comments
Use @ PropertySource annotation to indicate the path of configuration file, and introduce multiple configuration files at the same time can use @ PropertySources annotation
PropertySource (value = {"classpath:application-left.properties"}) @ PropertySources ({@ PropertySource (value = "classpath:application.properties", encoding = "UTF-8")})
Data injection / / single numeric value, can be injected as int or String@Value ("${val}") private int val;// array @ Value ("# {${list} '.split (',')}") private List list;//map@Value ("# {${map}}") private Map map;//map of list@Value ("# {${map.of.list}}") private Map map
Test result
ten
[1, 2, 3, 4]
{name=chen, age=12, sex= male}
{KEY1= [value1, value2], KEY2= [value3, value4], KEY3= [value5]}
At this point, on the "springboot application.properties file injection array is what is the end of the study, I hope to be able to solve your doubts." The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.