2.1 父工程搭建
搭建一个普通的IDEA Java项目,作为父工程
3. Rest微服务构建
3.1 Cloud-Provider-Payment-8001 微服务提供者Module模块
3.1.1 项目介绍
使用8001端口对外进行服务,使用Mybatis作为持久层框架,hikari作为数据库连接池
3.1.2 application.yml 配置
server:
port: 8001
spring:
application:
name: cloud-payment-service
datasource:
url: jdbc:mysql://localhost:3306/titancloud?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
type: com.zaxxer.hikari.HikariDataSource
hikari:
username: root
password: titan123
driver-class-name: com.mysql.cj.jdbc.Driver
mybatis:
configuration:
map-underscore-to-camel-case: true
cache-enabled: true
3.1.3 服务实现
“Talk is cheap, show me the code. ”
服务实现具体过程不再赘述,基本上就是一个独立的SpringBoot项目,实现了Payment的查询和增加功能,详情查阅Cloud-Provider-Payment-8001的源码。
3.2 Cloud-Consumer-Order-80 微服务消费者Order模块
使用RestTemplate来调用Cloud-Provider-Payment-8001中提供的接口
3.3 项目重构
新建一个子模块Cloud-Common,将beans包中的实体类统一放置于该子模块中
执行maven clean 和 maven install,将子模块打包
其他子模块以dependency方式引入Cloud-Common module,实现实体类共享
文章评论