增加集成Dubbo的demo

This commit is contained in:
zlt2000
2021-01-30 12:02:49 +08:00
parent 880b599bc2
commit 30b87fdbaf
9 changed files with 187 additions and 21 deletions
@@ -0,0 +1,20 @@
package org.zlt;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* @author zlt
* @date 2020/1/30
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@EnableDiscoveryClient
@SpringBootApplication
public class WebDubboApp {
public static void main(String[] args) {
SpringApplication.run(WebDubboApp.class, args);
}
}
@@ -0,0 +1,28 @@
package org.zlt.controller;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.zlt.service.RpcService;
/**
* @author zlt
* @date 2020/6/26
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@Slf4j
@RestController
public class WebController {
@DubboReference
private RpcService dubboService;
@GetMapping("/test/{p}")
public String test(@PathVariable("p") String param) {
log.info("==============WebController");
return dubboService.test(param);
}
}
@@ -0,0 +1,12 @@
package org.zlt.service;
/**
* @author zlt
* @date 2020/1/30
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
public interface RpcService {
String test(String param);
}
@@ -0,0 +1,22 @@
package org.zlt.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.zlt.service.RpcService;
/**
* @author zlt
* @date 2020/1/30
* <p>
* Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
@Slf4j
@DubboService(protocol = "dubbo")
public class RpcServiceImpl implements RpcService {
@Override
public String test(String param) {
log.info("==============RpcServiceImpl");
return "dubbo service: " + param;
}
}