当前位置: 首页 > news >正文

中国建设银行春季招聘网站网站seo技术能不能赚钱

中国建设银行春季招聘网站,网站seo技术能不能赚钱,杭州公司官方网站制作,杭州资质代办公司排名目录 环境搭建 Dubbo的3种使用方式: 1. XML配置的方式,一般用于Spring MVC工程 2. 配置文件的方式 (spring boot工程) 3. 注解方式 Dubbo 控制台 环境搭建 本篇将介绍Spring boot zookeeper Dubbo 简易环境的搭建以及使用…

目录

环境搭建

Dubbo的3种使用方式:

1. XML配置的方式,一般用于Spring MVC工程

2. 配置文件的方式 (spring boot工程)

3. 注解方式

Dubbo 控制台


环境搭建

本篇将介绍Spring boot + zookeeper + Dubbo 简易环境的搭建以及使用,首先准备好一台虚拟机。

1. 在虚拟机上安装JDK8及以上版本,可以参考我的另一篇博客 https://www.cnblogs.com/chen1-kerr/p/6907280.html

2. 在虚拟机上安装zookeeper。可以是单机,也可以是集群。可以参考我的文件

单机: zookeeper 单机环境搭建(三)_chen_yao_kerr的博客-CSDN博客 

集群: zookeeper集群(二)_zookeeper集群相互发现_chen_yao_kerr的博客-CSDN博客 

3. 新建2个spring boot工程,一个是Server端,一个是client端,并且引入zookeeper 和 dubbo依赖的jar包。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>dubbo-basic</artifactId><groupId>com.enjoy</groupId><version>1.0</version></parent><modelVersion>4.0.0</modelVersion><artifactId>busi-xml-server-client</artifactId><dependencies><dependency><groupId>com.enjoy</groupId><artifactId>busi-api</artifactId><version>1.0</version></dependency><!-- spring支持 --><dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>${spring.version}</version></dependency><!-- dubbo --><dependency><groupId>com.alibaba</groupId><artifactId>dubbo-config-spring</artifactId><version>${dubbo.version}</version></dependency><!-- zookeeper注册中心 --><dependency><groupId>com.alibaba</groupId><artifactId>dubbo-registry-zookeeper</artifactId><version>${dubbo.version}</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>dubbo-rpc-dubbo</artifactId><version>${dubbo.version}</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>dubbo-remoting-netty</artifactId><version>${dubbo.version}</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>dubbo-serialization-hessian2</artifactId><version>${dubbo.version}</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>${junit_version}</version></dependency></dependencies>
</project>

 我本次使用的虚拟机IP是 192.168.0.105。 因此,需要到这台虚拟机服务器上启动zookeeper

抽象出接口:

Dubbo的3种使用方式:

1. XML配置的方式,一般用于Spring MVC工程

服务端(Server)

服务端需要去实现这个接口,因为这个实现类要提供具体的业务处理逻辑:

服务端的xml配置

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.1.xsdhttp://code.alibabatech.com/schema/dubbohttp://code.alibabatech.com/schema/dubbo/dubbo.xsd"><!--全局配置--><dubbo:provider timeout="3000" /><!-- 服务提供方应用名称, 方便用于依赖跟踪 --><dubbo:application name="busi-server"/><!-- 使用本地zookeeper作为注册中心 --><dubbo:registry address="zookeeper://192.168.0.105:2181" /><!--name指示使用什么协议监听端口:dubbo/rmi/rest--><dubbo:protocol id="d1"  name="dubbo" port="20880" /><dubbo:protocol id="d2"  name="dubbo" port="20882" /><!-- 通过xml方式配置为bean, 让spring托管和实例化 --><bean id="orderService" class="com.enjoy.service.OrderServiceImpl"/><!-- 声明服务暴露的接口,并暴露服务 --><dubbo:service interface="com.enjoy.service.OrderService" ref="orderService" protocol="d1" />
</beans>

、客户端(Consumer):

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.1.xsdhttp://code.alibabatech.com/schema/dubbohttp://code.alibabatech.com/schema/dubbo/dubbo.xsd"><dubbo:application name="busi-client" /><dubbo:registry address="zookeeper://192.168.0.105:2181" /><dubbo:consumer /><dubbo:reference id="orderService" interface="com.enjoy.service.OrderService" /></beans>

启动Server:

启动客户端:

2. 配置文件的方式 (spring boot工程)

首先在Server端定义配置文件:

开放一个业务类:

服务端加载配置:

在Consumer端定义配置文件

定义一个类,这个类要从远程服务器上拿到需要使用的实例

消费端调用:

3. 注解方式

这种方式其实和第2种方式基本一致,唯一的不同就是少了个配置文件,这个配置文件,多了些注入的类:

服务端代码:

/***   Licensed to the Apache Software Foundation (ASF) under one or more*   contributor license agreements.  See the NOTICE file distributed with*   this work for additional information regarding copyright ownership.*   The ASF licenses this file to You under the Apache License, Version 2.0*   (the "License"); you may not use this file except in compliance with*   the License.  You may obtain a copy of the License at**       http://www.apache.org/licenses/LICENSE-2.0**   Unless required by applicable law or agreed to in writing, software*   distributed under the License is distributed on an "AS IS" BASIS,*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*   See the License for the specific language governing permissions and*   limitations under the License.**/package com.enjoy.dubbo.annotation;import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.ProviderConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;public class Provider {public static void main(String[] args) throws Exception {AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);context.start();System.out.println("---------dubbo启动成功--------");System.in.read();}@Configuration@EnableDubbo(scanBasePackages = "com.enjoy.service")static class ProviderConfiguration {@Beanpublic ProviderConfig providerConfig() {ProviderConfig providerConfig = new ProviderConfig();providerConfig.setTimeout(1000);return providerConfig;}@Beanpublic ApplicationConfig applicationConfig() {ApplicationConfig applicationConfig = new ApplicationConfig();applicationConfig.setName("busi-provider");return applicationConfig;}@Beanpublic RegistryConfig registryConfig() {RegistryConfig registryConfig = new RegistryConfig();registryConfig.setProtocol("zookeeper");registryConfig.setAddress("192.168.0.105");registryConfig.setPort(2181);return registryConfig;}@Beanpublic ProtocolConfig protocolConfig() {ProtocolConfig protocolConfig = new ProtocolConfig();protocolConfig.setName("dubbo");protocolConfig.setPort(20880);return protocolConfig;}}}

客户端:

/***   Licensed to the Apache Software Foundation (ASF) under one or more*   contributor license agreements.  See the NOTICE file distributed with*   this work for additional information regarding copyright ownership.*   The ASF licenses this file to You under the Apache License, Version 2.0*   (the "License"); you may not use this file except in compliance with*   the License.  You may obtain a copy of the License at**       http://www.apache.org/licenses/LICENSE-2.0**   Unless required by applicable law or agreed to in writing, software*   distributed under the License is distributed on an "AS IS" BASIS,*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*   See the License for the specific language governing permissions and*   limitations under the License.**/package com.enjoy.dubbo.annotation;import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ConsumerConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import com.enjoy.action.ServiceConsumer;
import com.enjoy.entity.OrderEntiry;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;public class Consumer {public static void main(String[] args) {AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);context.start();System.out.println("---------dubbo启动成功--------");ServiceConsumer serviceConsumer = context.getBean(ServiceConsumer.class);OrderEntiry entiry = serviceConsumer.getDetail("1");System.out.println("result: " + entiry.getMoney());}@Configuration@EnableDubbo(scanBasePackages = "com.enjoy.action")@ComponentScan(value = {"com.enjoy.action"})static class ConsumerConfiguration {@Beanpublic ApplicationConfig applicationConfig() {ApplicationConfig applicationConfig = new ApplicationConfig();applicationConfig.setName("busi-consumer");return applicationConfig;}@Beanpublic ConsumerConfig consumerConfig() {ConsumerConfig consumerConfig = new ConsumerConfig();consumerConfig.setTimeout(3000);return consumerConfig;}@Beanpublic RegistryConfig registryConfig() {RegistryConfig registryConfig = new RegistryConfig();registryConfig.setProtocol("zookeeper");registryConfig.setAddress("192.168.0.105");registryConfig.setPort(2181);return registryConfig;}}
}

其实,具体怎么用,可根据实际情况进行选择。如果是Spring MVC工程,选第一种方式比较好。如果是Spring boot工程,我个人倾向于选择第二种方式,也就是注解+配置文件的方式。

Dubbo 控制台

dubbo-admin 的地址为: mirrors / apache / dubbo-admin · GitCode 

但是,我使用命令拉下来总是少文件,所有我直接下载的zip包解压。

 修改配置:

 编译并启动:

能打开页面,能够登录即可:

上方介绍了集中服务端启动的方式,选择任意一种方式启动服务端代码,如果在控制台能够发现即可:

http://www.hengruixuexiao.com/news/14601.html

相关文章:

  • 政务门户网站建设方案seo网络推广公司报价
  • 烟台网站优化推广优化设计七年级下册数学答案
  • 网站开发遇到的问题有创意的营销案例
  • 太原cms建站模板网络推广深圳有效渠道
  • 专业网站建设商家域名检测
  • wordpress导入ppt宁波网站推广优化外包
  • 网站宽度设置永久免费建站系统
  • 上海网站推广费用娄底seo
  • 企业做网站的目的是什么我要下载百度
  • muse cc 做网站信阳seo优化
  • myeclipse做网站更改名字怎么找到当地的微信推广
  • 网络营销推广公司名字seo标题优化裤子关键词
  • 网站开发中期检查网站流量统计系统
  • 做网站的基本功企业为何选择网站推广外包?
  • 网站建设 独立ip大型的营销型网站
  • 辽宁省阜蒙县建设局网站营销型网站更受用户欢迎的原因是
  • 珠海市建设局网站徐州seo网站推广
  • 嘉兴网站建设方案服务百度知道官网首页登录入口
  • 公司门户网站首页aso关键词优化计划
  • 网站如何做快捷支付拉新推广怎么做代理
  • 网站设计合同模板小红书seo排名
  • weex做的网站哈尔滨百度网络推广
  • 网站页面大小公司网站设计报价
  • 福建省建设注册执业管理中心网站亚洲长尾关键词挖掘
  • 赌博网站怎么做的网络销售技巧和话术
  • wordpress插件销售石家庄百度快照优化
  • syntaxhighlighter wordpress网站seo属于什么专业
  • 浏览器无法打开住房和建设网站seo属于运营还是技术
  • 朝阳市做网站的公司公司推广渠道
  • 阿里巴巴网站建设策略调研西安seo外包服务