标签:sys servlet 监控中心 led targe registry mpi efault stat
SpringBoot融合了maven的特点,所以可以和maven完美整合
接下来要做一个分布式项目,首先要有共享的接口
先建一个maven项目
详情:
UserAddress.java
package com.changping.bean; |
OrderService.java
package com.changping.service; |
UserService.java
package com.changping.service; |
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" <dependencies> <dependency> <dependency> <dependency> <!-- 2.Spring --> <!-- 3.MyBatis --> <!-- 4.SpringMVC --> <!-- 5.辅助 --> </dependency> <dependency> <dependency> <dependency> <!-- 6.webservice-cxf --> <!-- 1 spring容器事务 --> |
以上项目会作为下面两个项目的依赖
新建springboot项目用来提供服务
UserServiceImpl.java
package com.changping.mall.userserviceimpl; |
SpringbootUserserviceProviderApplication (启动)
package com.changping.mall; |
application.properties(配置信息)
dubbo.application.name=user-service-provider
dubbo.registry.protocol=zookeeper dubbo.protocol.name=dubbo dubbo.monitor.protocol=registry |
SpringbootUserserviceProviderApplicationTests (单元测试)
package com.changping.mall; |
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" |
此时可以启动zkServer、zkCli、然后打包发布到web上
zkServer.cmd
zkCli.cmd
java -jar dubbo-admin-0.0.1-SNAPSHOT.jar
接下来去浏览器访问
http://localhost:7001
首页
接着启动服务提供者
console信息
SLF4J: Class path contains multiple SLF4J bindings. :: Dubbo Spring Boot (v0.2.0) : https://github.com/apache/incubator-dubbo-spring-boot-project 2020-03-30 15:26:11.180 INFO 13804 --- [ main] e.OverrideDubboConfigApplicationListener : Dubbo Config was overridden by externalized configuration {dubbo.application.name=order-service-consumer, dubbo.monitor.protocol=registry, dubbo.registry.address=zookeeper://127.0.0.1:2181} . ____ _ __ _ _ 2020-03-30 15:26:11.661 INFO 13804 --- [ main] pringbootOrderserviceConsumerApplication : Starting SpringbootOrderserviceConsumerApplication on DESKTOP-NF046H7 with PID 13804 (D:\workspace\springboot\springboot-orderservice-consumer\target\classes started by YZ in D:\workspace\springboot\springboot-orderservice-consumer) |
可以看到浏览器
新建springboot项目提供消费者
OrderController.java
package com.changping.mall.controller; |
OrderServiceImp.java
package com.changping.mall.orderserviceimp; |
SpringbootOrderserviceConsumerApplication(启动)
package com.changping.mall; |
application.properties(配置文件)
dubbo.application.name=order-service-consumer |
pom.xml
<?xml version="1.0" encoding="UTF-8"?> <properties> <dependencies> <dependency> <dependency> <build> |
需要双击启动start.bat
首先看一下配置文件,其中jetty.port之前为8080,需要修改一下为8081,避免与tomecat冲突:
双击start.bat后:
可以去浏览器访问一下,如图是注册中心
可以看一下services,此时还没有消费者
SpringbootOrderserviceConsumerApplication启动消费者应用
console信息
SLF4J: Class path contains multiple SLF4J bindings. :: Dubbo Spring Boot (v0.2.0) : https://github.com/apache/incubator-dubbo-spring-boot-project 2020-03-30 17:44:00.517 INFO 12428 --- [ main] e.OverrideDubboConfigApplicationListener : Dubbo Config was overridden by externalized configuration {dubbo.application.name=order-service-consumer, dubbo.monitor.protocol=registry, dubbo.registry.address=zookeeper://127.0.0.1:2181} . ____ _ __ _ _ 2020-03-30 17:44:00.761 INFO 12428 --- [ main] pringbootOrderserviceConsumerApplication : Starting SpringbootOrderserviceConsumerApplication on DESKTOP-NF046H7 with PID 12428 (D:\workspace\springboot\springboot-orderservice-consumer\target\classes started by YZ in D:\workspace\springboot\springboot-orderservice-consumer) |
注册中心
这样就也有注册中心了
分别将提供者和消费者再启动一次,仔细观察一下吧(我的电脑有些hold不住了,如果三个生产者,三个消费者,就基本可以和博客说拜拜了):
先从监控中心开始
首页服务治理
系统管理
服务
应用
机器
提供者
消费者
路由规则
动态配置
访问控制
权重调节
负载均衡
负责人
系统管理
dubbo版本
系统快照
系统状态
系统日志(有130条)
系统环境
接下来看看注册中心
Home
Application
Service
Hosts
Registries
Servers
Status
Log
System
好啦,就到这里吧,下节再见。
SpringBoot和Dubbo+ZooKeeper组合案例
标签:sys servlet 监控中心 led targe registry mpi efault stat
原文地址:https://www.cnblogs.com/timingstarts/p/12599237.html