Spring Boot整合Dubbo&Zookeeper
This commit is contained in:
parent
75895af88f
commit
f0666cc0f6
|
|
@ -39,10 +39,11 @@
|
|||
</dependency>
|
||||
<!-- dubbo -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.spring.boot</groupId>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>0.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- zookeeper -->
|
||||
<dependency>
|
||||
<groupId>org.apache.zookeeper</groupId>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package cc.mrbird;
|
||||
|
||||
import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration;
|
||||
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@EnableDubbo
|
||||
@SpringBootApplication
|
||||
@EnableDubboConfiguration
|
||||
public class Applicaiton {
|
||||
public class ConsumerApplicaiton {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Applicaiton.class, args);
|
||||
SpringApplication.run(ConsumerApplicaiton.class, args);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,13 @@
|
|||
server:
|
||||
port: 8081
|
||||
spring:
|
||||
dubbo:
|
||||
application:
|
||||
# 服务名称,保持唯一
|
||||
name: server-consumer
|
||||
# zookeeper地址,用于向其注册服务
|
||||
registry:
|
||||
address: zookeeper://127.0.0.1:2181
|
||||
protocol:
|
||||
# dubbo协议,固定写法
|
||||
name: dubbo
|
||||
# 扫描需要调用服务的类路径
|
||||
scan: cc.mrbird.consumer.controller
|
||||
|
||||
dubbo:
|
||||
application:
|
||||
# 服务名称,保持唯一
|
||||
name: server-consumer
|
||||
# zookeeper地址,用于从中获取注册的服务
|
||||
registry:
|
||||
address: zookeeper://127.0.0.1:2181
|
||||
protocol:
|
||||
# dubbo协议,固定写法
|
||||
name: dubbo
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
package cc.mrbird;
|
||||
|
||||
import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration;
|
||||
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@EnableDubbo
|
||||
@SpringBootApplication
|
||||
@EnableDubboConfiguration
|
||||
public class Applicaiton {
|
||||
public class ProviderApplicaiton {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Applicaiton.class, args);
|
||||
SpringApplication.run(ProviderApplicaiton.class, args);
|
||||
System.out.println("complete");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +1,16 @@
|
|||
server:
|
||||
port: 8080
|
||||
spring:
|
||||
dubbo:
|
||||
application:
|
||||
# 服务名称,保持唯一
|
||||
name: server-provider
|
||||
# zookeeper地址,用于向其注册服务
|
||||
registry:
|
||||
address: zookeeper://127.0.0.1:2181
|
||||
#暴露服务方式
|
||||
protocol:
|
||||
# dubbo协议,固定写法
|
||||
name: dubbo
|
||||
# 暴露服务端口 (默认是20880,不同的服务提供者端口不能重复)
|
||||
port: 20880
|
||||
server: true
|
||||
# 扫描需要暴露服务的类路径
|
||||
scan: cc.mrbird.provider.service
|
||||
|
||||
dubbo:
|
||||
application:
|
||||
# 服务名称,保持唯一
|
||||
name: server-provider
|
||||
# zookeeper地址,用于向其注册服务
|
||||
registry:
|
||||
address: zookeeper://127.0.0.1:2181
|
||||
#暴露服务方式
|
||||
protocol:
|
||||
# dubbo协议,固定写法
|
||||
name: dubbo
|
||||
# 暴露服务端口 (默认是20880,不同的服务提供者端口不能重复)
|
||||
port: 20880
|
||||
Loading…
Reference in New Issue