@Autowired
private SystemConstants systemConstants;
List<SysConfig> list = sysConfigDao.selectAllParam();
list.forEach(one->{
String key=one.getParamKey();
String value=one.getParamValue();
key= StrUtil.toCamelCase(key);
try {
//反射写法,获取指定系统参数类对应字段
Field field = systemConstants.getClass().getField("key");
//当前对象对应字段赋值
field.set(systemConstants,value);
}catch (Exception e){
}
});
循环去设置spring创建的对象systemConstants的值 这样是会出现多个SystemConstants类 对象吗?