You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "SKYhuangjing (GitHub)" <gi...@apache.org> on 2019/03/01 14:52:26 UTC

[GitHub] [incubator-dubbo] SKYhuangjing opened issue #3588: Dubbo 配置中心能否支持在启动前加载

例如 Apollo 客户端提供的 [Java客户端使用指南#3213-spring-boot集成方式推荐](https://github.com/ctripcorp/apollo/wiki/Java%E5%AE%A2%E6%88%B7%E7%AB%AF%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97#3213-spring-boot%E9%9B%86%E6%88%90%E6%96%B9%E5%BC%8F%E6%8E%A8%E8%8D%90)
``` 
    # will inject 'application' namespace in bootstrap phase
    apollo.bootstrap.enabled = true
```

原因在于, 希望在 bean 加载前, 就将远程的配置注入环境, 保证 bean 使用的远程配置能正常加载

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3588 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] SKYhuangjing commented on issue #3588: Dubbo 配置中心能否支持在启动前加载

Posted by "SKYhuangjing (GitHub)" <gi...@apache.org>.
在服务端的服务实现者有一个属性使用 spring `@value` 注解, 当服务者的本地配置文件托管到远程配置中心后, 希望可以在 bean 加载前, 将远程配置先加载到本地
虽然在 nacos 本身提供了 `@nacosValue` 注解, 但是希望在 dubbo 2.7.0 的配置中心中, 能够支持这种行为
自己写的 [demo](https://github.com/SKYhuangjing/dubbo-nacos-demo/blob/master/dubbo-nacos-provider/src/main/java/com/sky/dubbo/nacos/demo/provider/service/impl/DefaultService.java)
![image](https://user-images.githubusercontent.com/13705011/53709801-13745e80-3e75-11e9-9c68-ded6e1fe4485.png)
![image](https://user-images.githubusercontent.com/13705011/53709826-3999fe80-3e75-11e9-94ae-799d9ae093a4.png)


[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3588 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] kuchensheng commented on issue #3588: Dubbo 配置中心能否支持在启动前加载

Posted by "kuchensheng (GitHub)" <gi...@apache.org>.
配置中心可以在启动前加载。我已在springboot中实现。代码示例见
https://github.com/kuchensheng/mermaid-framework-parent/blob/develop/modules/mermaid-core/src/main/java/com/mermaid/framework/core/MermaidApplicationEntry.java
欢迎指正

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3588 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] mercyblitz commented on issue #3588: Dubbo 配置中心能否支持在启动前加载

Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
`@Value` is naturally supported in Spring Framework 3.x, thus you could use it safely.

There maybe is an issue for Config center in Pic 2.

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3588 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] mercyblitz commented on issue #3588: Dubbo 配置中心能否支持在启动前加载

Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
`@Value` is naturally supported in Spring Framework 3.x+, thus you could use it safely.

There maybe is an issue for Config center in Pic 2.

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3588 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [incubator-dubbo] SKYhuangjing commented on issue #3588: Dubbo 配置中心能否支持在启动前加载

Posted by "SKYhuangjing (GitHub)" <gi...@apache.org>.
嗯, 麻烦小马哥在适配 nacos 配置中心, 关注下这个 issue

debug 过现有配置中心的代码, 配置中心的启动逻辑是在服务导出时加载的, 所以这个时候 bean 已经加载完成,  所以提供提前加载配置到 spring 环境中, 我觉得有这个实际场景
![image](https://user-images.githubusercontent.com/13705011/53714985-5b9e7b80-3e8b-11e9-934d-c3ff12d948cb.png)


[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3588 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [incubator-dubbo] mercyblitz commented on issue #3588: Dubbo 配置中心能否支持在启动前加载

Posted by "mercyblitz (GitHub)" <gi...@apache.org>.
What‘s the problem you met with? Do you try to annotate `@Reference(lazy=true)` into Beans' fields?

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3588 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org