最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Dubbo+zookeeper搭配分布式服務(wù)的過程詳解

 更新時間:2022年04月03日 11:17:44   作者:我也不會敲代碼呀  
Dubbo作為分布式架構(gòu)比較后的框架,同時也是比較容易入手的框架,適合作為分布式的入手框架,下面是簡單的搭建過程,對Dubbo+zookeeper分布式服務(wù)搭建過程感興趣的朋友一起看看吧

分布式架構(gòu): 

1.當垂直應(yīng)用越來越多,應(yīng)用之間交互不可避免,將核心業(yè)務(wù)抽取出來,作為獨立的服務(wù),逐漸形成穩(wěn)定的服務(wù)中心,前端應(yīng)用能更快速的響應(yīng)多變的市場需求。 
2.此時,用于提高業(yè)務(wù)復用及整合的 分布式服務(wù)框架(RPC) 是關(guān)鍵。

Dubbo 是什么

  • 一款分布式服務(wù)框架
  • 高性能和透明化的RPC遠程服務(wù)調(diào)用方案
  • SOA服務(wù)治理方案

Dubbo:

作為分布式架構(gòu)比較后的框架,同時也是比較容易入手的框架,適合作為分布式的入手框架,下面是簡單的搭建過程

工具:idea+tomact+zookeeper (知識點:jsp,spring,springmvc,maven)

思想:

 

依賴:

<dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.2.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.2.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <version>2.6.2</version>
        </dependency>
        <!--zookeeper依賴-->
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-framework</artifactId>
            <version>4.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.atchengdu</groupId>
            <artifactId>001-interface</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>

工程分布:

  

provider實現(xiàn)interface提供服務(wù),constomer消費provider提供的服務(wù)

interface:

package com.atchengdu.serviceinterface;
 
import com.atchengdu.pojo.User;
public interface Userservice {
    //獲取user的信息
    User getuserByid(Integer ie);
}
package com.atchengdu.pojo;
import java.io.Serializable;
public class User implements Serializable {
    private Integer id ;
    private String name;
    public User(Integer id, String name) {
        this.id = id;
        this.name = name;
    }
    public User() {
    public Integer getId() {
        return id;
    public void setId(Integer id) {
    public String getName() {
        return name;
    public void setName(String name) {
    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';

 provider:

package com.atchengdu.Modulserviceimpl;
 
import com.atchengdu.pojo.User;
import com.atchengdu.serviceinterface.Userservice;
public class Userserviceimpl implements Userservice {
    @Override
    public User getuserByid(Integer ie) {
        User user=new User(1,"張三");
        return user;
    }
}
<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
    <!--聲明名稱-->
    <dubbo:application name="002-provider"></dubbo:application>
    <!--設(shè)置協(xié)議和端口號-->
    <dubbo:protocol name="dubbo" port="20880"></dubbo:protocol>
    <!--使用注冊中心-->
    <dubbo:registry address="zookeeper://localhost:2181"></dubbo:registry>
    <!--暴露服務(wù)接口-->
    <dubbo:service interface="com.atchengdu.serviceinterface.Userservice" ref="userserviceimpl"></dubbo:service>
    <!--加載業(yè)務(wù)實實現(xiàn)了-->
    <bean id="userserviceimpl" class="com.atchengdu.Modulserviceimpl.Userserviceimpl"></bean>
</beans>

constomer:

package com.atchengdu.webcontroller;
 
import com.atchengdu.pojo.User;
import com.atchengdu.serviceinterface.Userservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
 
@Controller
public class Usercontroller {
    @Autowired
    private Userservice userservice;
    @RequestMapping("/user")
    public  String user(Model model,Integer id ){
        User user = userservice.getuserByid(id);
        model.addAttribute("user",user);
        return "user";
    }
}
<?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:aop="http://www.springframework.org/schema/aop"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:tx="http://www.springframework.org/schema/task"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
                            http://www.springframework.org/schema/task https://www.springframework.org/schema/task/spring-task.xsd
                           http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd
                           http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.atchengdu.webcontroller">
</context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
    <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="suffix" value=".jsp"></property>
        <property name="prefix" value="/"></property>
     </bean>
</beans>
<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
      <dubbo:application name="003-constomer"></dubbo:application>
    <dubbo:registry address="zookeeper://localhost:2181"></dubbo:registry>
    <dubbo:reference id="userservice" interface="com.atchengdu.serviceinterface.Userservice"></dubbo:reference>
</beans>

到此這篇關(guān)于Dubbo+zookeeper搭配分布式服務(wù)的過程詳解的文章就介紹到這了,更多相關(guān)Dubbo+zookeeper分布式服務(wù)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • swing中Tree與滾動條用法實例分析

    swing中Tree與滾動條用法實例分析

    這篇文章主要介紹了swing中Tree與滾動條用法,以實例形式分析了java基于swing實現(xiàn)圖形界面的使用技巧,需要的朋友可以參考下
    2015-09-09
  • eclipse輸出Hello World的實現(xiàn)方法

    eclipse輸出Hello World的實現(xiàn)方法

    這篇文章主要介紹了eclipse輸出Hello World的實現(xiàn)方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-11-11
  • SpringCloud GateWay動態(tài)路由用法

    SpringCloud GateWay動態(tài)路由用法

    網(wǎng)關(guān)作為所有項目的入口,不希望重啟,因此動態(tài)路由是必須的,動態(tài)路由主要通過RouteDefinitionRepository接口實現(xiàn),其默認的實現(xiàn)是InMemoryRouteDefinitionRepository,即在內(nèi)存中存儲路由配置,可基于這個map對象操作,動態(tài)路由的實現(xiàn)方案有兩種
    2024-10-10
  • JavaFx 中創(chuàng)建計時器的步驟詳解

    JavaFx 中創(chuàng)建計時器的步驟詳解

    本文介紹了如何在JavaFx中創(chuàng)建計時器,通過創(chuàng)建計時器界面、編寫計時器邏輯以及關(guān)聯(lián)計時器按鈕,我們可以快速實現(xiàn)一個靈活可靠的計時器組件,本文能夠幫助讀者在 JavaFx 中成功實現(xiàn)自己的計時器功能,感興趣的朋友一起看看吧
    2023-11-11
  • Java常用集合之Set和Map的用法詳解

    Java常用集合之Set和Map的用法詳解

    這篇文章將通過一些示例為大家詳細介紹一下Java常用集合中Set和Map的用法,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下
    2022-07-07
  • Java字節(jié)碼增強技術(shù)知識點詳解

    Java字節(jié)碼增強技術(shù)知識點詳解

    在本篇文章里小編給大家整理的是一篇關(guān)于Java字節(jié)碼增強技術(shù)知識點詳解內(nèi)容,有興趣的朋友可以跟著學習下。
    2021-08-08
  • Java裁剪壓縮PNG圖片,透明背景色變黑的解決方案

    Java裁剪壓縮PNG圖片,透明背景色變黑的解決方案

    這篇文章主要介紹了Java裁剪壓縮PNG圖片,透明背景色變黑的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-11-11
  • 微信公眾號測試賬號自定義菜單的實例代碼

    微信公眾號測試賬號自定義菜單的實例代碼

    這篇文章主要介紹了微信公眾號測試賬號自定義菜單的實例代碼,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2017-02-02
  • 實例解決Java異常之OutOfMemoryError的問題

    實例解決Java異常之OutOfMemoryError的問題

    在本篇文章中,我們給大家分享了關(guān)于解決Java異常之OutOfMemoryError的問題的方法,有此需要的朋友們學習下。
    2019-02-02
  • Eclipse遠程debug的步驟與注意事項

    Eclipse遠程debug的步驟與注意事項

    今天小編就為大家分享一篇關(guān)于Eclipse遠程debug的步驟與注意事項,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-03-03

最新評論

含山县| 方城县| 新密市| 若羌县| 若羌县| 徐州市| 丘北县| 罗平县| 蓝山县| 孟村| 延安市| 武隆县| 长泰县| 凌海市| 昌都县| 丰县| 宁德市| 甘孜| 寿阳县| 紫金县| 乳源| 长子县| 石门县| 澄迈县| 桓仁| 高清| 包头市| 民丰县| 泸定县| 双流县| 绵阳市| 舞阳县| 崇信县| 武威市| 肇州县| 时尚| 西乡县| 开封县| 府谷县| 扎鲁特旗| 东阳市|