用SpringCloud Alibaba搭建属于自己的微服务(三十三)~业务开发~支付接口开发

一.概述

本文本打算接入微信支付和支付宝支付作为讲解,但是没有弄到微信和支付宝的商户账户.所以支付将只会讲解扣除账户余额的方式.

二.新建server-pay微服务

1.创建server-pay的maven工程.

在这里插入图片描述

2.引入maven工程依赖.

 <dependencies>
        <dependency>
            <groupId>com.ccm</groupId>
            <artifactId>assembly-mysql</artifactId>
            <version>1.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>

    </dependencies>

3.编写工程的启动类.

package com.ccm.server.pay;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Description server-pay服务启动类
 * @Author ccm
 * @CreateTime 2020/8/19 14:18
 */
@EnableFeignClients
@EnableDiscoveryClient //注册中心客户端
@ComponentScan(basePackages = "com.ccm")
@EnableSwagger2
@MapperScan(basePackages = "com.ccm.server.pay.dao.mysql.mapper")
@SpringBootApplication //声明为一个启动类
@Import(value = {
   PaginationInterceptor.class})
public class ServerPayApplication {
   
    public static void main(String[] args) {
   
        SpringApplication.run(ServerPayApplication.class,args);
    }
}

4.编写bootstrap.yml配置文件.

server:
  port: 5000  #服务端口
spring:
  application:
    name: server-pay #服务名称
  cloud:
    nacos:
      discovery:
        server-addr: 47.96.131.185:8849
      config:
        server-addr: 47.96.131.185:8849  #nacos config配置中心ip和端口
        file-extension: yaml  #文件扩展名格式,针对于默认的{spring.application.name}-${profile}.${file-extension:properties}配置
        enabled: true #开启或关闭配置中心
  datasource:
    username: root
    password: Test2016@
    url: jdbc:mysql://47.96.131.185:3306/pay?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true
    type: com.alibaba.druid.pool.DruidDataSource
mybatis-plus:
  typeAliasesPackage: com.ccm.server.pay.dao.mysql.domain  #数据库实体类包
  mapper-locations: classpath:mappering/*.xml #xml文件扫描

#自定义配置
server-order:
  serverNumber: 1  #机器服务号

5.swagger配置.

package com.ccm
  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值