这次一起编写课程服务。之前的用户服务,用户EdgeSerivce,用户信息,都已经开发完毕了,开始开发课程服务,对外的是dubbo接口,需要访问后端的数据库。源码:https://github.com/limingios/msA-docker
基于dubbo的服务,一般先定义api接口,前面的都是基于thrift的,我们先写一个thrift的文件,然后根据配置文件升成对应的api,dubbo我们相当于先手写一个api的模块。
总体思想
>就不在复制代码了只通过截图来讲述功能,可以参考源码,本次跟用到了上次springboot集成dubbo的方式。
<?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>
PS:基本的课程开发思路就是这样,别人有的微服务调用,只实现自己所属的。
百度未收录
>>原创文章,欢迎转载。转载请注明:转载自IT人故事会,谢谢!
>>原文链接地址:上一篇:已是最新文章