Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

nacos加载yml配置文件中的信息时机太早,出现某些包还没有处理完yml配置,nacos无法获取正确的配置 #12101

Open
aiYunS-love opened this issue May 15, 2024 · 9 comments
Labels
area/Spring Boot Related to Spring Boot status/invalid This doesn't seem right

Comments

@aiYunS-love
Copy link

例子:
我对yml中的所有ip地址进行了加密操作,springboot启动加载时,应当加载解密之后的信息,但是nacos很早就要加载nacos服务的地址,导致获取的是加密的ip,无法连接nacos服务.redis,rabbitmq等软件都是正常加载的,请提高通用型 兼容性
WX20240515-144734@2x

@aiYunS-love
Copy link
Author

Uploading WX20240515-162923@2x.png…

@aiYunS-love
Copy link
Author

nacos:
config:
server-addr: ${encpt.ip}:38848

@aiYunS-love
Copy link
Author

encpt:
ip: ENC(LDhWy5HYSN5OtWL25iAB3APJ+OTACf/P)

@aiYunS-love aiYunS-love changed the title nacox加载yml配置文件中的信息时机太早,出现某些包还没有处理完yml配置,nacos无法获取正确的配置 nacos加载yml配置文件中的信息时机太早,出现某些包还没有处理完yml配置,nacos无法获取正确的配置 May 15, 2024
@KomachiSion
Copy link
Collaborator

和nacos无关, bean的加载顺序是应用程序和spring控制的, 如果需要使用解密starter,请自行确保解密starter在配置加载之后执行。

@KomachiSion KomachiSion added status/invalid This doesn't seem right area/Spring Boot Related to Spring Boot labels May 24, 2024
@KomachiSion
Copy link
Collaborator

或者有什么方案可以提供,以无侵入的方式确保能够保证解密

@aiYunS-love
Copy link
Author

aiYunS-love commented May 24, 2024

和nacos无关, bean的加载顺序是应用程序和spring控制的, 如果需要使用解密starter,请自行确保解密starter在配置加载之后执行。

你们的机制肯定有问题! 加密方式是通用的三方包jasypt-spring-boot-starter, 都是交给spring管理的,从日志的输出也可以看出, 你们nacos的加载时机早于redis或者rabbitmq等,经过测试只有nacos加密不行, 单独把nacos的换成明文是可以的.

@aiYunS-love
Copy link
Author

或者有什么方案可以提供,以无侵入的方式确保能够保证解密

我感觉你们像是用了一些侵入式的方式 强制优先加载了你们的内容

@KomachiSion
Copy link
Collaborator

那可以帮助社区排查一下问题,以更好的兼容这个场景。

一般来说,配置的加载肯定要早于其他的starter,比如redis等,否则redis之类的starter已经完成初始化配置的时候, 配置还没有从nacos中读取,那肯定是有问题的。

@aiYunS-love
Copy link
Author

aiYunS-love commented May 29, 2024

那可以帮助社区排查一下问题,以更好的兼容这个场景。

一般来说,配置的加载肯定要早于其他的starter,比如redis等,否则redis之类的starter已经完成初始化配置的时候, 配置还没有从nacos中读取,那肯定是有问题的。

这样说是有道理的 本身也是管理配置的 优先级高还是有道理的 有空我研究下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/Spring Boot Related to Spring Boot status/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants