Skip to content

Commit

Permalink
DubboConfig optimise
Browse files Browse the repository at this point in the history
  • Loading branch information
javahongxi committed Dec 3, 2018
1 parent 7de3583 commit c267f25
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ public class DubboConfig {

/**
* 配置文件里配置默认的,这里配置其他需要的
* @param otherZK
* @return
*/
@Bean("otherZK")
public RegistryConfig registryConfig(@Value("${registry.zk.other}") String otherZK) {
@Bean("otherRegistry")
public RegistryConfig otherRegistry(@Value("${registry.other.address}") String address,
@Value("${registry.other.id}") String id) {
RegistryConfig registry = new RegistryConfig();
registry.setId("otherZK");
registry.setAddress(otherZK);
registry.setAddress(address);
registry.setId(id);
return registry;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class DemoRpc {
@Reference(version = "1.0.0")
private DemoService demoService;

@Reference(version = "1.0.0", registry = "otherZK")
@Reference(version = "1.0.0", registry = "otherRegistry")
private OtherService otherService;

public String sayHello(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ dubbo:
qosPort: 22224

registry:
zk:
other: zookeeper://127.0.0.1:2181
other:
address: zookeeper://127.0.0.1:2181
id: other
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ public class DubboConfig {

/**
* 配置文件里配置默认的,这里配置其他需要的
* @param otherZK
* @return
*/
@Bean("otherZK")
public RegistryConfig registryConfig(@Value("${registry.zk.other}") String otherZK) {
@Bean("otherRegistry")
public RegistryConfig otherRegistry(@Value("${registry.other.address}") String address,
@Value("${registry.other.id}") String id) {
RegistryConfig registry = new RegistryConfig();
registry.setId("otherZK");
registry.setAddress(otherZK);
registry.setAddress(address);
registry.setId(id);
return registry;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
version = "1.0.0",
application = "${dubbo.application.id}",
protocol = "${dubbo.protocol.id}",
registry = "otherZK"
registry = "otherRegistry"
)
public class OtherServiceImpl implements OtherService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ management:
enabled: false

registry:
zk:
other: zookeeper://127.0.0.1:2181
other:
address: zookeeper://127.0.0.1:2181
id: other

0 comments on commit c267f25

Please sign in to comment.