【自撰】Springboot集成Zookeeper和Dubbo

【自撰】Springboot集成Zookeeper和Dubbo,第1张

【自撰】Springboot集成Zookeeper和Dubbo Springboot集成Zookeeper和Dubbo
            
                org.springframework.boot
                spring-boot-starter-web
                2.6.2
            
            
            
                org.springframework.boot
                spring-boot-test
                2.6.2
            
            
            
                com.alibaba.boot
                dubbo-spring-boot-starter
                0.2.0
            
            
            
                com.baomidou
                mybatis-plus-boot-starter
                3.4.3.4
            
            
            
                mysql
                mysql-connector-java
                8.0.27
            
            
            
                org.projectlombok
                lombok
                1.18.22
            
            
            
                com.mchange
                c3p0
                0.9.5.2
            
            
            
                com.google.code.gson
                gson
                2.8.5
            
解决消费者子模块的yml必须要写dataSource
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
项目结构

消费者的启动类
@EnableDubbo
@SpringBootApplication
@MapperScan(basePackages = "com.guigu.www.mapper")
public class DubboProviderApplication {
    public static void main(String[] args) {
        SpringApplication.run(DubboProviderApplication.class,args);
    }
}
消费者的yml配置
server:
  port: 8200

spring:
  application:
    name: boot-zookeeper-dubbo-consumer

dubbo:
  application:
    name: boot-zookeeper-dubbo-consumer
  protocol:
    name: dubbo
    port: 20882
  registry:
    address: zookeeper://192.168.43.17:2181
@EnableDubbo

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class DubboConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(DubboConsumerApplication.class,args);
    }
}
提供者yml配置
server:
  port: 8100

dubbo:
  application:
    name: boot-zookeeper-dubbo-proivder
  protocol:
    name: dubbo
    port: 20880
  registry:
    address: zookeeper://192.168.43.17:2181

spring:
  application:
    name: boot-zookeeper-dubbo-proivder
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql:///test
    username: root
    password: 123456

注意以上yml的dubbo端口不能重复。

参考项目:点击获取springboot+zookeeper+dubbo

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5681322.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存