Spring Boot整合Dubbo
2017-12-07 09:14
369 查看
1.pom.xml 添加相关依赖。dubbo选择2.5.7及以上版本
<dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>2.5.7</version> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-framework</artifactId> <version>4.0.0</version> </dependency> <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>3.4.9</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> </exclusions> </dependency>
2. 添加配置dubbo的Configuration类
@Configuration public class ProfileConsumerDubboConfiguration { @Autowired private ProfileProperties config; @Bean(name = "profileApplicationConfig") public ApplicationConfig applicationConfig(){ ApplicationConfig applicationConfig = new ApplicationConfig(); applicationConfig.setName("profile-present-service"); applicationConfig.setOwner("profile"); applicationConfig.setOrganization("touna"); return applicationConfig; } @Bean(name = "profileConsumerConfig") public ConsumerConfig consumerConfig() { ConsumerConfig consumerConfig = new ConsumerConfig(); consumerConfig.setTimeout(config.getTimeout()); return consumerConfig; } @Bean(name = "profileRegistryConfig") public RegistryConfig registryConfig() { RegistryConfig registryConfig = new RegistryConfig(); registryConfig.setAddress(config.getAddress()); //如果协议是zookeeper,则依赖zookeeper registryConfig.setClient("curator"); //依赖curator-framework return registryConfig; } @Bean public ProfileVariableConfService profileVariableConfService(){ ReferenceConfig<ProfileVariableConfService> reference = new ReferenceConfig<>(); reference.setApplication(applicationConfig()); reference.setRegistry(registryConfig()); // 多个注册中心可以用setRegistries() reference.setInterface(ProfileVariableConfService.class); return reference.get(); } }
相关文章推荐
- Springboot整合Dubbo - 项目创建和环境搭建
- springboot dubbo的整合以及与springcloud fein的对比
- Spring Boot整合Dubbo框架demo
- Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例
- Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例
- spring boot 与dubbo 2.8.4整合的一些问题
- Spring Boot整合Dubbo开发系列(一)----一个简单的示例
- Spring-boot:5分钟整合Dubbo构建分布式服务 - jaycekong - 博客园
- springboot整合dubbo
- Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例
- Spring-boot整合Dubbo构建分布式开发配置
- spring-boot整合dubbo
- 解密Spring Boot整合Dubbo RPC框架
- Spring Boot整合Dubbo框架demo
- springboot整合dubbo
- spring boot 学习笔记(3) 整合dubbo
- Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例
- Spring Boot和Dubbo整合
- 使用spring boot搭建与dubbo整合项目
- Spring-boot:5分钟整合Dubbo构建分布式服务