Closed FengJinghHua closed 3 years ago
nacosValue应该不支持这个操作。
@KomachiSion ok~ 我试过在赋值是给了string类型,然后再指定一个list类型,如下:
@NacosValue(value = "${support.type:,#)}",
autoRefreshed = true)
String type1;
private List
不幸的是,启动的时候会报空指针异常,是和nacos启动时机有关系吗,或者说,如果要实现类似@value split 的功能,有workaround吗
应该和启动顺序有关。
是否实现类似的功能需要看社区的反馈,看看是否社区中有人愿意贡献,如果社区里需求的人数比较多,我们也会提高这个功能的优先级。
@KomachiSion ok~ 我试过在赋值是给了string类型,然后再指定一个list类型,如下:
@NacosValue(value = "${support.type:,#)}", autoRefreshed = true) String type1; private List familyList = Arrays.asList(type1.split(","));
不幸的是,启动的时候会报空指针异常,是和nacos启动时机有关系吗,或者说,如果要实现类似@value split 的功能,有workaround吗
这个我来搞搞,和spring一样支持el表达式是吗。
@horizonzy 是的,这样的使用应该很普遍
@horizonzy 是的,这样的使用应该很普遍
Hi, 最新的代码已经被合到nacos-spring-project,如果想要使用这个特性的话,可以单独对nacos-spring-project打包使用
spring中@value注解可以进行string的split并赋值为list对象,如下: @Value("#{'${support.type}'.split(',')}") Set supportType;
这个在@nacosValue中应该如何写才能得到对应效果?please help 我试过 @NacosValue(value = "${support.type:,#}split(',')}", autoRefreshed = true) 但是取到的值是["","#}split(", "')}"] 而不是 ["*", "#"] please help,thanks