亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

『高級篇』docker之開發課程服務(15)

標簽:
Docker

webp

开发课程服务模块

基于dubbo的服务,一般先定义api接口,前面的都是基于thrift的,我们先写一个thrift的文件,然后根据配置文件升成对应的api,dubbo我们相当于先手写一个api的模块。

webp

稍微复杂

  • 总体思想

就不在复制代码了只通过截图来讲述功能,可以参考源码,本次跟用到了上次springboot集成dubbo的方式。

  1. course-dubbo-service-api   是负责提供接口的服务

  2. course-dubbo-service 是course-dubbo-service-api的实现

  3. course-dubbo-service 需要依赖原始的user-thrift-service-api的原生DTO类 和 user-thrift-service中的方法实现。

  4. course-dubbo-service调用user-thrift-service 是用过thrift的方式完成的调用。因为user-thrift-service本身就是通过thrift生成对应的java类。

webp

webp

  • user-thrift-service 和 user-thrift-service-api

  1. user-thrift-service-api 做了thrift的修改,增加了老师的DTO和ID来获取用户的信息,所以需要重新通过thrift命令生成对应的java类

  2. user-thrift-service  实现了新增的通过ID来获取用户的信息的接口,并增加了UserMapper

  3. user数据库中增加了一张关联表teacher表

webp

webp

webp

webp

webp

webp

  • course-dubbo-service-api 和 course-dubbo-service

  1. course-dubbo-service pom中引入了springboot,mysql的驱动,thrift,springboot-dubbo,user-thrift-service.jar,user-thrift-service-api.jar

  2. course-dubbo-service 中注入thrift微服务的访问service,获取教师针对课程的教程信息访问user-thrift-service的微服务,通过thrift的方式。

  3. application.properties 配置dubbo的配置,数据库配置,user-thrift-service的地址和端口

<?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>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.3.RELEASE</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.idig8</groupId>
    <artifactId>course-dubbo-service</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>io.dubbo.springboot</groupId>
            <artifactId>spring-boot-starter-dubbo</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.thrift</groupId>
            <artifactId>libthrift</artifactId>
            <version>0.10.0</version>
        </dependency>

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.1</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.44</version>
        </dependency>
        <dependency>
            <groupId>com.idig8</groupId>
            <artifactId>course-dubbo-service-api</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>com.idig8</groupId>
            <artifactId>user-thrift-service</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.idig8</groupId>
            <artifactId>user-thrift-service-api</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies></project>

webp

webp

webp

webp



作者:IT人故事会
链接:https://www.jianshu.com/p/bbadef9f1d57


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消