当前位置:网站首页>【config】配置数组参数
【config】配置数组参数
2022-07-29 04:55:00 【掘金者说】
环境配置
#经纬度
#经度(119.123) LNG,LON,LGTD
strong.ep.form.layer.onemap.point-jd-lng-list=LNG,LON,LGTD,lng,lon,lgtd
#纬度(212.321) LAT,LTTD
strong.ep.form.layer.onemap.point-wd-lat-list=LAT,LTTD,lat,lttd
获取配置
import cn.hutool.core.collection.CollectionUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/** * @description: 环境配置统一集中 * @author: Lucky * @create: 2022-07-27 15:24 **/
@Component
public class EnvUtils {
@Resource
private Environment env;
private static EnvUtils envUtils;
@PostConstruct
public void init() {
envUtils = this;
}
/** * 获取配置 * * @param message * @param defList 默认 * @return */
public static List<String> getConfigListDef(String message, List<String> defList) {
List<String> arrays = getConfigList(message);
if (CollectionUtil.isNotEmpty(arrays)) {
return arrays;
}
return defList;
}
/** * 获取配置 * * @param message * @return */
public static List<String> getConfigList(String message) {
List<String> arrayList = new ArrayList<>();
String arrayStr = envUtils.env.getProperty(message);
if (StringUtils.isNotBlank(arrayStr)) {
//兼容性处理中文逗号
arrayStr.replace(",", ",");
List<String> array = Arrays.asList(arrayStr.split(","));
array.stream().forEach(str -> {
if (StringUtils.isNotBlank(str)) {
arrayList.add(str.trim());
}
});
}
return arrayList;
}
}
使用参考
@Resource
private Cache cache;
//经度(119.123) LNG、LON、LGTD
private static final List<String> POINT_LONGITUDE = Arrays.asList("LNG", "LON", "LGTD", "lng", "lon", "lgtd");
//纬度(212.321) LAT、LTTD
private static final List<String> POINT_LATITUDE = Arrays.asList("LAT", "LTTD", "lat", "lttd");
//使用TODO
List<String> pointLng = (List<String>) cache.get(MyConstant.CACHE_POINT_LNG);
List<String> pointLat = (List<String>) cache.get(MyConstant.CACHE_POINT_LAT);
if (pointLng == null) {
pointLng = EnvUtils.getConfigListDef(MyConstant.POINT_JD_LNG_LIST, POINT_LONGITUDE );
cache.put(AppConstant.CACHE_POINT_LNG, pointLng);
}
if (pointLat == null) {
pointLat = EnvUtils.getConfigListDef(MyConstant.POINT_WD_LAT_LIST, POINT_LATITUDE );
cache.put(AppConstant.CACHE_POINT_LAT, pointLat);
}
边栏推荐
- Various configurations when pulsar starts the client (client, producer, consumer)
- How to solve the problem of configuring the progress every time Office2010 is opened?
- How to avoid damage of oscilloscope current probe
- Install the gym corresponding to mujoco in the spinning up tutorial, and the error mjpro150 is reported
- Force deduction ----- sort odd and even subscripts respectively
- Use openmap and ArcGIS to draw maps and transportation networks of any region, and convert OMS data into SHP format
- Five correlation analysis, one of the most important skills of data analysts
- Stack and queue and priority queue (large heap and small heap) simulation implementation and explanation of imitation function
- 使用近场探头和电流探头进行EMI干扰排查
- stack和queue和优先级队列(大堆和小堆)模拟实现和仿函数讲解
猜你喜欢

数据湖:分布式开源处理引擎Spark

What are the core features of the digital transformation of state-owned construction enterprises?

WPS插入超链接无法打开,提示“无法打开指定文件”怎么办!

使用更灵活、更方便的罗氏线圈

Force deduction ----- sort odd and even subscripts respectively

Stack and queue and priority queue (large heap and small heap) simulation implementation and explanation of imitation function
Let you understand several common traffic exposure schemes in kubernetes cluster

Use openmap and ArcGIS to draw maps and transportation networks of any region, and convert OMS data into SHP format

Traffic flow prediction pit climbing record (I): traffic flow data set, original data

让你的正则表达式可读性提高一百倍
随机推荐
How does word view document modification traces? How word views document modification traces
Various configurations when pulsar starts the client (client, producer, consumer)
Five correlation analysis, one of the most important skills of data analysts
What if excel is stuck and not saved? The solution of Excel not saved but stuck
Mysql各版本下载地址及多版本共存安装
How is the entered query SQL statement executed?
Take you to understand JS array
The most complete NLP Chinese and English stop words list in the whole station (including punctuation marks, which can be copied directly)
Use annotation test in idea
SparkSql批量插入或更新,保存数据到Mysql中
Common rules of makefile (make) (II)
MySQL time calculation function
JS daily question (12)
Conv1d of torch
Leetcode 763. partition labels divide alphabetic intervals (medium)
PHP判断用户是否已经登录,如果登录则显示首页,如果未登录则进入登录页面或注册页面
Force deduction ----- sort odd and even subscripts respectively
Let you understand several common traffic exposure schemes in kubernetes cluster
On prepayment of house purchase
Connection database time zone setting