Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

配置项value $符号异常 #293

Open
liaofuyan opened this issue Aug 23, 2022 · 9 comments
Open

配置项value $符号异常 #293

liaofuyan opened this issue Aug 23, 2022 · 9 comments
Labels
question Further information is requested

Comments

@liaofuyan
Copy link

String spelExpr = nacosValueExpr.replaceAll("\\$\\{" + key + PLACEHOLDER_SUFFIX, newValue);

如果配置的value中包含$符号,String.replaceAll()会抛出异常,导致配置无法更新

@hujun-w-2 hujun-w-2 added the bug Something isn't working label Sep 22, 2022
@caijunqian
Copy link

请问什么时候能修复,也遇到了同样的问题

@caijunqian
Copy link

@hujun-w-2

@hujun-w-2 hujun-w-2 removed the bug Something isn't working label Nov 12, 2022
@hujun-w-2
Copy link
Collaborator

正常情况下,配置内容包含$也是为了引用配置中的另一个值吧?还有配置内容本身就抱哈$的吗

@hujun-w-2
Copy link
Collaborator

这种情况可以把配置内容中的$换成 \$

@caijunqian
Copy link

感谢答复,我试配置内容本身就包含$,我试了一下换成\$ 符可以读取到$, 但是在使用@NacossValue刷新配置的时候会报错,刷新时使用\\$才不会报错,可以看一下这个链接 @hujun-w-2

@hujun-w-2
Copy link
Collaborator

我想说的就是换成 \\$ ,直接评论自动变成\$

@hujun-w-2 hujun-w-2 added question Further information is requested and removed need feedback labels Nov 16, 2022
@caijunqian
Copy link

启动应用读取配置,和使用@NacosValue刷新配置,读取规则不一样,导致使用\\$配置时,启动应用读取到\$,而刷新配置读取到$,二者不一致,具体可以看看上面的链接。

@liaofuyan
Copy link
Author

String spelExpr = nacosValueExpr.replaceAll("\$\{" + key + PLACEHOLDER_SUFFIX, Matcher.quoteReplacement(newValue));
做一下转义

codestagea pushed a commit to codestagea/nacos-spring-project that referenced this issue Aug 10, 2023
hujun-w-2 added a commit that referenced this issue May 9, 2024
Co-authored-by: huijun.xu <huijun.xu@urbanic.com>
Co-authored-by: 胡俊 <510830970@qq.com>
@hxc001
Copy link

hxc001 commented Sep 26, 2024

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants