dubbo

定义接口

public interface HelloService {
public String hello(String str);
}

发布到本地仓库

安装zookeeper

安装java

新建data目录

进入到conf目录,然后复制zoo_sample.cfg为zoo.cfg

dataDir=C:\wzxProgramData\zookeeper_data

进入 bin 目录,执行 zkServer.cmd

服务端

<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>

<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.11</version>
</dependency>

<dependency>
<groupId>com.wzx</groupId>
<artifactId>dubboApi</artifactId>
<version>1.0</version>
</dependency>
spring.application.name=dubbo-provider
spring.dubbo.server=true
spring.dubbo.registry=zookeeper://127.0.0.1:2181
import com.alibaba.dubbo.config.annotation.Service;
import com.wzx.service.HelloService;
import org.springframework.stereotype.Component;

@Service(interfaceClass = HelloService.class)
@Component
public class HelloServiceImpl implements HelloService {
@Override
public String hello(String str) {
System.out.println("hello");
return "hello "+str;
}
}
@EnableDubboConfiguration

客户端

<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>

<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.11</version>
</dependency>

<dependency>
<groupId>com.wzx</groupId>
<artifactId>dubboApi</artifactId>
<version>1.0</version>
</dependency>
server.port=8081
spring.application.name=dubbo-custom
spring.dubbo.registry=zookeeper://127.0.0.1:2181
import com.alibaba.dubbo.config.annotation.Reference;
import com.wzx.service.HelloService;
import org.springframework.stereotype.Service;

@Service
public class HelloServiceClient {
@Reference
HelloService helloService;
public String hello(String str){
return helloService.hello(str);
}

}
@RestController
@RequestMapping("/hello")
public class HelloController {
@Autowired
HelloServiceClient helloServiceClient;
@RequestMapping("/hello")
public String hello(){
return helloServiceClient.hello("hello");
}
}
@EnableDubboConfiguration

dubbo-admin

https://github.com/apache/incubator-dubbo-admin/tree/master

server.port=7001
spring.velocity.cache=false
spring.velocity.charset=UTF-8
spring.velocity.layout-url=/templates/default.vm
spring.messages.fallback-to-system-locale=false
spring.messages.basename=i18n/message
spring.root.password=root
spring.guest.password=guest

dubbo.registry.address=zookeeper://127.0.0.1:2181

http://127.0.0.1:7001/

用户名/密码:root/root

dubbo-monitor

dubbo.container=log4j,spring,registry,jetty-monitor
dubbo.application.name=simple-monitor
dubbo.application.owner=dubbo
#dubbo.registry.address=multicast://224.5.6.7:1234
dubbo.registry.address=zookeeper://127.0.0.1:2181
#dubbo.registry.address=redis://127.0.0.1:6379
#dubbo.registry.address=dubbo://127.0.0.1:9090
dubbo.protocol.port=7070
dubbo.jetty.port=8090
dubbo.jetty.directory=${user.home}/monitor
dubbo.charts.directory=${user.home}/monitor/charts
dubbo.statistics.directory=${user.home}/monitor/statistics
dubbo.log4j.file=logs/dubbo-monitor-simple.log
dubbo.log4j.level=WARN

http://127.0.0.1:8090/

参考资料

https://www.jianshu.com/p/f7037105db46

https://github.com/alibaba/dubbo-spring-boot-starter/blob/master/README_zh.md

https://www.cnblogs.com/jaycekon/p/SpringBootDubbo.html

https://blog.csdn.net/pri_sta_pub/article/details/79087592

https://www.cnblogs.com/Bruce3555/p/7255441.html

https://blog.csdn.net/qq_31748587/article/details/84883504

https://blog.csdn.net/zzqw199012/article/details/79643878

发表评论

电子邮件地址不会被公开。