>网站服务器>服务器租用>59.37.85.62佛山高防使用springb.. 免费发布服务器租用信息
广告
热门浏览

59.37.85.62佛山高防使用springboot服务器构建dubbo

更新时间:2018-10-23 19:40:01 信息编号:217731345
59.37.85.62佛山高防使用springboot服务器构建dubbo
1≥ 1台
  • 1.00 元

  • intel

  • 机架式

  • 高防服务器租用,佛山高防,构建dubbo,享带宽

分享

详情介绍

服务项目
高防服务器租用,佛山高防,构建dubbo,享带宽
面向地区
全国
品牌
intel
服务器类型
机架式
CPU类型
I5
内存类型
DDR3
CPU核心
四核
OEM
标配CPU个数
1个
标配硬盘转速
10000转
磁盘阵列
RAID1
货源类别
现货
结构
1U
硬盘容量
500GB
支持内存容量
8GB
质保
一年
大CPU个数
1个
类型
其它

59.37.85.62佛山高防使用springboot服务器构建dubbo

高防服务器租用 请联系:锐辉网络--小敏 电话: 同号
锐辉网络科技有限公司 官网:
springboot是基于注解配置,比起以往的springMVC臃肿的xml配置(虽然springMVC也可以使用注解进行配置),可以快速、简便地搭建起web服务。
dubbo是阿里的一个分布式开源框架。
搭建步骤:
一、本地安装zookeeper并启动服务
二、使用 idea新建一个springboot工程
三、在pom.xml中添加配置,使用dubbo和zkclient(zookeeper的客户端)的maven仓库。
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>0.1</version>
</dependency>
四、dubbo相关配置:
基础配置,注册服务和协议
* DubboBaseConfig.java
*/
import com.alibaba.dubbo.config.*;
import org.springframework.context.annotation.Bean;
public class DubboBaseConfig {
@Bean
public RegistryConfig registry() {
RegistryConfig registryConfig = new RegistryConfig();
registryConfig.setAddress("127.0.0.1:2181");
registryConfig.setProtocol("zookeeper");
return registryConfig;
@Bean
public ApplicationConfig application() {
ApplicationConfig applicationConfig = new ApplicationConfig();
applicationConfig.setName("testApp");
return applicationConfig
@Bean
public MonitorConfig monitorConfig() {
MonitorConfig mc = new MonitorConfig();
mc.setProtocol("registry");
return mc;
@Bean
public ReferenceConfig referenceConfig() {
ReferenceConfig rc = new ReferenceConfig();
rc.setMonitor(monitorConfig());
return rc;
@Bean
public ProtocolConfig protocol() {
ProtocolConfig protocolConfig = new ProtocolConfig();
protocolConfig.setPort(20880);
return protocolConfig;
@Bean
public ProviderConfig provider() {
ProviderConfig providerConfig = new ProviderConfig();
providerConfig.setMonitor(monitorConfig());
return providerConfig;
服务方配置
* Export.java
*/
import com.alibaba.dubbo.config.spring.ServiceBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Export extends DubboBaseConfig{
@Bean
public ServiceBean<Person> personProvider(Person person) {
ServiceBean<Person> serviceBean = new ServiceBean<Person>();
serviceBean.setProxy("javassist");
serviceBean.setVersion("myversion");
serviceBean.setInterface(Person.class.getName());
serviceBean.setRef(person);
serviceBean.setTimeout(5000);
serviceBean.setRetries(3);
return serviceBean;
消费方配置
* Consumer.java
*/
import com.alibaba.dubbo.config.spring.ReferenceBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Consumer extends DubboBaseConfig{
@Bean
public ReferenceBean<Person> personConsumer() {
ReferenceBean<Person> ref = new ReferenceBean<>();
ref.setVersion("myversion");
ref.setInterface(Person.class);
ref.setTimeout(5000);
ref.setRetries(3);
ref.setCheck(false);
return ref;
五、实例
声明接口 Person
public interface Person {
String talk();
服务方编写实现逻辑
import org.springframework.stereotype.Service;
@Service("person")
public class PersonImpl implements Person {
@Override
public String talk() {
return "Provider personImpl method";
服务方启动服务后,消费方声明跟服务方一样的dubbo基础配置和接口。
消费方不知道具体的实现逻辑,直接启动服务,调用接口。
@Autowired
Consumer consumer;
@RequestMapping("/consumer")
@ResponseBody
public String refer(){
return consumer.personConsumer().get().talk();

相关推荐产品

留言板

  • 高防服务器租用佛山高防构建dubbo享带宽
  • 价格商品详情商品参数其它
  • 提交留言即代表同意更多商家联系我
东莞市锐辉网络有限公司为你提供的“59.37.85.62佛山高防使用springboot服务器构建dubbo”详细介绍,包括高防服务器租用价格、型号、图片、厂家等信息。如有需要,请拨打电话:18316411879。不是你想要的产品?点击发布采购需求,让供应商主动联系你。
“59.37.85.62佛山高防使用springboot服务器构建dubbo”信息由发布人自行提供,其真实性、合法性由发布人负责。交易汇款需谨慎,请注意调查核实。