-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
Apollo配置能否调整优先级低于本地文件appsettings.json配置和命令行 #210
Comments
你可以在ConfigureHostConfiguration里添加Apollo,这样就比appsettings.json和命令行优先级低;或者builder.Sources.Insert(0) |
谢谢:)。 另外使用builder.Sources.Insert(0),不知道怎么做?我要从现有的builder.Source获取到Apollo的Provider吗,然后移除掉重新Insert到0吗,如果这样也挺麻烦的。 |
默认apollo需要的配置会配置在appsettings.json里,如果是这样,AddApollo()你最好使用一个带IApolloOptions参数的重载 |
试过了,不行;在刚进入这个方法之前,其他的Provider已经加载进去了。 |
没关系啊,appsettings.json是在ConfigureAppConfiguration中添加的 |
我也碰到类似的情况, 需要手动调整顺序, 研究了一番找不到很好的方式. 如果本地调试要覆盖一些参数, 建议在launchSettings.json里面通过环境变量注入. |
项目接入Apollo后, 相同Key下Apollo的配置优先级最高,因为按照官方.net core配置的介绍,Apollo是最后加载的,所以优先级高。这样会导致本地appsettings.json和命令行的优先级会低于Apollo配置,对于开发本地调试或其他场景不太方便;虽然通过代码清除Provider:config.Sources.Clear(),然后再重新按照顺序加载;这样可以解决问题,但比较麻烦。不知道Apollo.Net能否支持指定Provider优先级,像Spring一样。
The text was updated successfully, but these errors were encountered: