一、jeepay开源支付平台
码云地址:https://gitee.com/jeequan
1、介绍
支持多渠道服务商和普通商户模式。已对接微信支付,支付宝,云闪付官方接口,支持聚合码支付。
Jeepay使用Spring Boot和Ant Design Vue开发,集成Spring Security实现权限管理功能,是一套非常实用的web开发框架。
分为商户平台和运营平台,运行运营平台后添加商户,然后通过运营平台添加的商户账号登录商户平台。
2、技术栈和本地运行流程
2-1:拉取代码
https://gitee.com/jeequan/jeepay.git
2-2:idea运行
新建数据库jeepaydb,修改账号密码
导入SQL
修改manager模块pom文件,注释掉directory
添加依赖
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<!-- 作为可执行jar -->
<build>
<finalName>${project.artifactId}</finalName>
<!-- resources资源配置项 -->
<resources>
<!-- 通用资源文件 -->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<!-- 放置通用配置yml文件, 开发时仅配置一套参数即可。 实际生产环境下应在每个项目下 与jar同级目录下新建application.yml覆写对应参数。 -->
<resource>
<!-- <directory>../conf/devCommons</directory>-->
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>*.yml</include>
</includes>
<filtering>true</filtering>
<!-- <includes><include>**/*.yml</include></includes>-->
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
</plugins>
</build>
修改merchant依赖
添加jaxb-api
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
</dependencies>
<!-- 作为可执行jar -->
<build>
<finalName>${project.artifactId}</finalName>
<!-- resources资源配置项 -->
<resources>
<!-- 通用资源文件 -->
<resource><directory>src/main/resources</directory><includes><include>**/*.*</include></includes></resource>
<!-- 放置通用配置yml文件, 开发时仅配置一套参数即可。 实际生产环境下应在每个项目下 与jar同级目录下新建application.yml覆写对应参数。 -->
<resource>
<!-- <directory>../conf/devCommons</directory>-->
<!-- <includes><include>**/*.yml</include></includes>-->
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>*.yml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
</plugins>
</build>
修改payment依赖
修改yml文件
运行本地的activemq文件
打开service批量运行spring boot
拉取前端代码
后面基本流程参照官方文档:https://docs.jeequan.com/docs/jeepay/deploy3、配置好自己的支付宝和微信支付的参数
登录运营平台(jeepay jeepay123)添加商户,然后登录商户平台,添加支付参数
(jeepay jeepay666)
4、通过Java版的客户端测试一下支付
拉取代码:git clone https://gitee.com/jeequan/jeepay-sdk-java.git修改参数
ApiBase :自己运行的JeepayPayApplication这个服务的地址
ApiKey:运营平台配置商户应用信息生成的
appid和mchNo也是创建商户,添加应用自动生成的。
测试支付
测试支付代码报错可以升级一下版本,我的是1.3.0报错了,升级一下ok。
项目集成Java版的sdk
使用若依的开源项目测试项目集成,或者在自己项目添加依赖
<dependency>
<groupId>com.jeequan</groupId>
<artifactId>jeepay-sdk-java</artifactId>
<version>1.5.0</version>
</dependency>
支付代码
private static final String apiBase = "http://192.168.100.88:19216";
private static final String apiKey = "Fe7S9fIwehlgc3RS7PBNsUWx9jyribGl8t0NLFzq7mqaLp123skmFnojlnb1jwBn5SVdasknsJ3M90xFuwYXlaY7QXvF161rROudbgUT9JbssEfgMuW2AJoQcI";
private static final String mchNo = "M165541237365";
private static final String appId = "62abf8312362066beaa3ddf";
static {
Jeepay.setApiBase(apiBase);
Jeepay.apiKey = apiKey;
Jeepay.mchNo = mchNo;
Jeepay.appId = appId;
}
@Override
public String prePay(String wayCode, String orderNo, Long amount, String subject, String body, String notifyUrl,String clientIp) {
JeepayClient jeepayClient = JeepayClient.getInstance(Jeepay.appId, Jeepay.apiKey, Jeepay.getApiBase());
Assert.notNull(wayCode,"支付方式不能为空");
PayOrderCreateRequest request = new PayOrderCreateRequest();
PayOrderCreateReqModel model = new PayOrderCreateReqModel();
model.setMchNo(Jeepay.mchNo); // 商户号
model.setAppId(jeepayClient.getAppId()); // 应用ID
if (StringUtils.isBlank(orderNo)) {
orderNo = "mho" + System.currentTimeMillis();
}
model.setMchOrderNo(orderNo); // 商户订单号
model.setWayCode(wayCode); // 支付方式
model.setAmount(amount); // 金额,单位分
model.setCurrency("CNY"); // 币种,目前只支持cny
model.setClientIp(clientIp); // 发起支付请求客户端的IP地址
model.setSubject(subject); // 商品标题
model.setBody(body); // 商品描述
model.setNotifyUrl(notifyUrl); // 异步通知地址
model.setReturnUrl(""); // 前端跳转地址
//model.setChannelExtra(channelExtra(wayCode)); // 渠道扩展参数
model.setExtParam(""); // 商户扩展参数,回调时原样返回
request.setBizModel(model);
PayOrderCreateResponse response = null;
try {
response = jeepayClient.execute(request);
log.info("验签结果:{}", response.checkSign(Jeepay.apiKey));
// 下单成功
if(response.isSuccess(Jeepay.apiKey)) {
String payOrderId = response.get().getPayOrderId();
log.info("payOrderId:{}", payOrderId);
log.info("mchOrderNo:{}", response.get().getMchOrderNo());
}else {
log.info("下单失败:{}", orderNo);
log.info("通道错误码:{}", response.get().getErrCode());
log.info("通道错误信息:{}", response.get().getErrMsg());
}
} catch (JeepayException e) {
log.error(e.getMessage());
}
return response.getData().toString();
}
订单查询
public void testPayOrderQuery() {
// 支付接口文档:https://docs.jeequan.com/docs/jeepay/payment_api
JeepayClient jeepayClient = JeepayClient.getInstance(Jeepay.appId, Jeepay.apiKey, Jeepay.getApiBase());
PayOrderQueryRequest request = new PayOrderQueryRequest();
PayOrderQueryReqModel model = new PayOrderQueryReqModel();
model.setMchNo(Jeepay.mchNo); // 商户号
model.setAppId(jeepayClient.getAppId()); // 应用ID
model.setPayOrderId("P202106181104177050002"); // 支付订单号
request.setBizModel(model);
try {
PayOrderQueryResponse response = jeepayClient.execute(request);
_log.info("验签结果:{}", response.checkSign(Jeepay.apiKey));
if(response.isSuccess(Jeepay.apiKey)) {
_log.info("订单信息:{}", response);
_log.info("金额:{}", response.get().getAmount());
}
} catch (JeepayException e) {
e.printStackTrace();
}
}
关闭订单
public void testPayOrderClose() {
JeepayClient jeepayClient = new JeepayClient();
PayOrderCloseRequest request = new PayOrderCloseRequest();
PayOrderCloseReqModel model = new PayOrderCloseReqModel();
model.setMchNo(Jeepay.mchNo); // 商户号
model.setAppId(Jeepay.appId);
model.setPayOrderId("P1485879219030011906"); // 支付订单号
request.setBizModel(model);
try {
PayOrderCloseResponse response = jeepayClient.execute(request);
_log.info("验签结果:{}", response.checkSign(Jeepay.apiKey));
if(response.isSuccess(Jeepay.apiKey)) {
_log.info("返回信息:{}", response);
}
} catch (JeepayException e) {
e.printStackTrace();
}
}
退款测试
public void testRefundOrderCreate() {
// 接口文档:https://docs.jeequan.com/docs/jeepay/refund_api
JeepayClient jeepayClient = JeepayClient.getInstance(Jeepay.appId, Jeepay.apiKey, Jeepay.getApiBase());
RefundOrderCreateRequest request = new RefundOrderCreateRequest();
RefundOrderCreateReqModel model = new RefundOrderCreateReqModel();
model.setMchNo(Jeepay.mchNo); // 商户号
model.setAppId(jeepayClient.getAppId()); // 应用ID
model.setMchOrderNo(""); // 商户支付单号(与支付订单号二者传一)
model.setPayOrderId("P202106181104177050002"); // 支付订单号(与商户支付单号二者传一)
String refundOrderNo = "mho" + new Date().getTime();
model.setMchRefundNo(refundOrderNo); // 商户退款单号
model.setRefundAmount(4l); // 退款金额,单位分
model.setCurrency("cny"); // 币种,目前只支持cny
model.setClientIp("192.166.1.132"); // 发起支付请求客户端的IP地址
model.setRefundReason("退款测试"); // 退款原因
model.setNotifyUrl("https://www.jeequan.com"); // 异步通知地址
model.setChannelExtra(""); // 渠道扩展参数
model.setExtParam(""); // 商户扩展参数,回调时原样返回
request.setBizModel(model);
try {
RefundOrderCreateResponse response = jeepayClient.execute(request);
_log.info("验签结果:{}", response.checkSign(Jeepay.apiKey));
// 判断退款发起是否成功(并不代表退款成功)
if(response.isSuccess(Jeepay.apiKey)) {
String refundOrderId = response.get().getRefundOrderId();
_log.info("refundOrderId:{}", refundOrderId);
_log.info("mchRefundNo:{}", response.get().getMchRefundNo());
}else {
_log.info("下单失败:refundOrderNo={}, msg={}", refundOrderNo, response.getMsg());
_log.info("通道错误码:{}", response.get().getErrCode());
_log.info("通道错误信息:{}", response.get().getErrMsg());
}
} catch (JeepayException e) {
_log.error(e.getMessage());
}
}
转账
public void testTransferOrderCreate() {
// 转账接口文档:https://docs.jeequan.com/docs/jeepay/transfer_api
JeepayClient jeepayClient = JeepayClient.getInstance(Jeepay.appId, Jeepay.apiKey, Jeepay.getApiBase());
TransferOrderCreateRequest request = new TransferOrderCreateRequest();
TransferOrderCreateReqModel model = new TransferOrderCreateReqModel();
model.setMchNo(Jeepay.mchNo); // 商户号
model.setAppId(jeepayClient.getAppId()); // 应用ID
model.setMchOrderNo("mho" + new Date().getTime()); // 商户转账单号
model.setAmount(1L);
model.setCurrency("CNY");
model.setIfCode("wxpay");
model.setEntryType("WX_CASH");
model.setAccountNo("a6BcIwtTvIqv1zXZohc61biryWok");
model.setAccountName("");
model.setTransferDesc("测试转账");
model.setClientIp("192.166.1.132"); // 发起转账请求客户端的IP地址
request.setBizModel(model);
try {
TransferOrderCreateResponse response = jeepayClient.execute(request);
_log.info("验签结果:{}", response.checkSign(Jeepay.apiKey));
// 判断转账发起是否成功(并不代表转账成功)
if(response.isSuccess(Jeepay.apiKey)) {
String transferId = response.get().getTransferId();
_log.info("transferId:{}", transferId);
_log.info("mchOrderNo:{}", response.get().getMchOrderNo());
}else {
_log.info("下单失败:mchOrderNo={}, msg={}", model.getMchOrderNo(), response.getMsg());
_log.info("通道错误码:{}", response.get().getErrCode());
_log.info("通道错误信息:{}", response.get().getErrMsg());
}
} catch (JeepayException e) {
_log.error(e.getMessage());
}
}
转账查询
public void testTransferOrderQuery() {
// 转账接口文档:https://docs.jeequan.com/docs/jeepay/transfer_api
JeepayClient jeepayClient = JeepayClient.getInstance(Jeepay.appId, Jeepay.apiKey, Jeepay.getApiBase());
TransferOrderQueryRequest request = new TransferOrderQueryRequest();
TransferOrderQueryReqModel model = new TransferOrderQueryReqModel();
model.setMchNo(Jeepay.mchNo); // 商户号
model.setAppId(jeepayClient.getAppId()); // 应用ID
model.setTransferId("T202108121543441860003"); // 转账单号
request.setBizModel(model);
try {
TransferOrderQueryResponse response = jeepayClient.execute(request);
_log.info("验签结果:{}", response.checkSign(Jeepay.apiKey));
if(response.isSuccess(Jeepay.apiKey)) {
_log.info("订单信息:{}", response);
_log.info("转账状态:{}", response.get().getState());
_log.info("转账金额:{}", response.get().getAmount());
}
} catch (JeepayException e) {
e.printStackTrace();
}
}
5、项目部署测试服务器验证
使用activemq
#################################
# spring boot支持外部application.yml 读取优先级为:
# 1、file:./config/(当前目录下的config文件夹)
# 2、file:./(当前目录)
# 3、classpath:/config/(classpath下的config目录)
# 4、classpath:/(classpath根目录)
# 建议: 如果是jar则放置到与jar相同的目录下, 如果解压文件放置到classpath: config目录下。 (需要将文件重命名为 application.yml )
#
# 该yml文件只配置与环境相关的参数, 其他配置读取项目下的配置项
#
#################################
server:
port: 9216 #设置端口
servlet:
context-path: / #设置应用的目录. 前缀需要带/, 无需设置后缀, 示例 【 /xxx 】 or 【 / 】
spring:
servlet:
multipart:
enabled: true #是否启用http上传处理
max-request-size: 10MB #最大请求文件的大小
max-file-size: 10MB #设置单个文件最大长度
resources:
static-locations: classpath:/static #项目静态资源路径 (可直接通过http访问)
freemarker:
template-loader-path: classpath:/templates #freemarker模板目录
template-encoding: UTF-8
suffix: .ftl
settings:
classic_compatible: true # 如果变量为null,转化为空字符串,比如做比较的时候按照空字符做比较
number_format: '#' #数字格式进行原样显示,不加格式化字符例如 100,00
datasource:
# yml填写url连接串, 无需将&符号进行转义
url: jdbc:mysql://127.0.0.1:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: abc=123
druid:
# 连接池配置项
initial-size: 5 #初始化时建立物理连接的个数
min-idle: 5 #最小连接池数量
max-active: 30 #最大连接池数量
max-wait: 60000 #获取连接时最大等待时间,单位毫秒
# 检测相关
test-while-idle: true # 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。
test-on-borrow: false # 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
test-on-return: false # 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
time-between-eviction-runs-millis: 60000 #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
min-evictable-idle-time-millis: 300000 #连接保持空闲而不被驱逐的最小时间
validation-query: SELECT 1 FROM DUAL
# 是否缓存preparedStatement
pool-prepared-statements: false # 是否缓存preparedStatement,也就是PSCache。PSCache对支持游标的数据库性能提升巨大,比如说oracle。在mysql下建议关闭。
max-pool-prepared-statement-per-connection-size: 20 # 要启用PSCache,必须配置大于0,当大于0时,poolPreparedStatements自动触发修改为true。
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计 通过connectProperties属性来打开mergeSql功能;慢SQL记录
filters: stat,wall
connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
cache:
type: redis
redis:
host: 127.0.0.1
port: 6379
database: 9 #1库:运营平台 #2库:商户系统 #3库:支付网关
timeout: 1000
password: abc123
# #activeMQ配置 ( 注意: activeMQ配置项需在spring的下级 )
activemq:
broker-url: failover:(tcp://127.0.0.1:61616?wireFormat.maxInactivityDuration=0) #连接地址
in-memory: false # Jeepay项目不可使用内存模式, 需要连接多个消费者。
user: system # activeMQ默认无需账密认证。 打开认证:activemq.xml添加simpleAuthenticationPlugin标签,账密在credentials.properties文件。
password: manager
pool:
enabled: true
max-connections: 10
idle-timeout: 30000 # 空闲的连接过期时间,默认为30秒
#
# #rabbitmq配置 ( 注意: rabbitmq配置项需在spring的下级 )
# rabbitmq:
# addresses: 127.0.0.1:5672
# username: rabbit
# password: rabbit
# dynamic: true
# virtual-host: /
## rocketmq配置 ( 注意:rocketmq配置项请放置到根目录, 不是spring的二级配置! )
#rocketmq:
# name-server: 127.0.0.1:9876
# producer:
# group: JEEPAY-GROUP
## 阿里云rocketmq配置 ( 注意:aliyun-rocketmq配置项请放置到根目录, 不是spring的二级配置!需要阿里云开通rocketMQ产品,创建Group和Topic )
#aliyun-rocketmq:
# namesrvAddr: xxx
# accessKey: xxx
# secretKey: xxx
# groupId: GID_JEEPAY_T
#日志配置参数。
# 当存在logback-spring.xml文件时: 该配置将引进到logback配置, springboot配置不生效。
# 不存在logback-spring.xml 文件时, 使用springboot的配置, 同样可用。
logging:
level:
root: info #主日志级别
com.jeequan.jeepay: debug #该项目日志级别,当需要打印sql时请开启为debug
file:
path: ./home/jeepay/service/payment/logs #日志存放地址
#系统业务参数
isys:
#是否允许跨域请求 [生产环境建议关闭, 若api与前端项目没有在同一个域名下时,应开启此配置或在nginx统一配置允许跨域]
allow-cors: true
#是否内存缓存配置信息: true表示开启如支付网关地址/商户应用配置/服务商配置等, 开启后需检查MQ的广播模式是否正常; false表示直接查询DB.
cache-config: false
oss:
file-root-path: /home/jeepay/upload #存储根路径 ( 无需以‘/’结尾 )
file-public-path: ${isys.oss.file-root-path}/public #公共读取块 ( 一般配合root-path参数进行设置,需以‘/’ 开头, 无需以‘/’结尾 )
file-private-path: ${isys.oss.file-root-path}/private #私有化本地访问,不允许url方式公共读取 ( 一般配合root-path参数进行设置,需以‘/’ 开头, 无需以‘/’结尾 )
# [local]: 本地存储,所有的文件将存在放本地,可通过nfs, rsync工具实现多机共享;
# [aliyun-oss]: 将文件统一上传到阿里云oss服务器; 注意:需调整jeepay-components-oss/pom.xml中的aliyun-sdk-oss组件依赖方式
service-type: local
# 阿里云OSS服务配置信息
aliyun-oss:
endpoint: oss-cn-beijing.aliyuncs.com #endpoint 如: oss-cn-beijing.aliyuncs.com
public-bucket-name: bucket1 #公共读 桶名称
private-bucket-name: bucket2 #私有 桶名称
access-key-id: KEY_KEY_KEY #AccessKeyId
access-key-secret: SECRET_SECRET_SECRET #AccessKeySecret
mq:
vender: activeMQ # 切换MQ厂商, 支持:【 activeMQ rabbitMQ rocketMQ aliYunRocketMQ 】, 需正确配置 【对应的yml参数】 和 【jeepay-components-mq项目下pom.xml中的依赖包】。
服务器环境初始化
安装docker
yum list installed | grep docker
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
sytstemctl status docker
sudo systemctl start docker
docker安装monio文件服务器
docker run -it --name minio -p 9000:9000 -p 9001:9001 -d -v /usr/local/docker/minio/data:/data -v /usr/local/docker/minio/config:/root/.minio -e 'MINIO_ROOT_USER=admin' -e 'MINIO_ROOT_PASSWORD=admin123' minio/minio server /data --console-address ":9001"
docker安装MySQL
这里使用docker run --name mysql -d -it --restart=always --net=host -v /opt/mysql/data:/var/lib/mysql -v /opt/mysql/conf:/etc/mysql -e MYSQL_ROOT_PASSWORD=abc=123 -e MYSQL_DATABASE=retirement-v2 mysql --default-time-zone=+8:00 --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
无法挂载MySQL配置文件目录,通过创建数据卷my.cnf和conf.d,防止容器启动的时候将本地的配置覆盖。以下命令通过数据卷可以直接将MySQL容器内的配置挂载出来。
查询挂载数据卷的目录
[root@localhost mysql]# docker volume ls
DRIVER VOLUME NAME
local mysql.conf
local mysql.data
[root@localhost mysql]# docker inspect mysql.conf
[
{
"CreatedAt": "2022-06-02T10:29:34+08:00",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/mysql.conf/_data",
"Name": "mysql.conf",
"Options": null,
"Scope": "local"
}
]
[root@localhost mysql]# cd /var/lib/docker/volumes/mysql.conf/_data
docker run --name mysql -d -it --restart=always --net=host --v /opt/mysql/data:/var/lib/mysql -v /opt/mysql/conf:/etc/mysql/conf.d -v /opt/mysql/my.cnf:/etc/mysql/my.cnf -e MYSQL_ROOT_PASSWORD=abc=123 -e MYSQL_DATABASE=jeepaydb mysql --default-time-zone=+8:00 --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
docker安装redis
docker run --name redis -d -it --net=host -e TZ=Asia/Shanghai redis redis-server --requirepass abc123
docker安装activemq
#下载镜像
docker pull webcenter/activemq
docker run --name activemq -d \
-p 8161:8161 \
-p 61616:61616 \
-p 61613:61613 \
webcenter/activemq
webcenter/activemq镜像启动没成功
#使用下面这个镜像成功
docker pull rmohr/activemq
docker run --name my-activemq -d \
-p 61616:61616 \
-p 8161:8161 rmohr/activemq
firewall-cmd --zone=public --add-port=5672/tcp --permanent
firewall-cmd --zone=public --add-port=15672/tcp --permanent
firewall-cmd --reload
开放防火墙端口
firewall-cmd --zone=public --add-port=5672/tcp --permanent
firewall-cmd --zone=public --add-port=15672/tcp --permanent
firewall-cmd --zone=public --add-port=19216/tcp --permanent
firewall-cmd --zone=public --add-port=19217/tcp --permanent
firewall-cmd --zone=public --add-port=19218/tcp --permanent
firewall-cmd --reload
安装nginx
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
cd /usr/local/src/
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
tar zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure
make && make install
pcre-config --version
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.6.2.tar.gz
cd nginx-1.6.2
./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
make
make install
/usr/local/webserver/nginx/sbin/nginx -v
/usr/local/webserver/nginx/sbin/nginx -t
配置nginx,在最后一行添加配置 include jeepay.conf;
vim /usr/local/webserver/nginx/conf/nginx.conf
添加配置:vi /usr/local/webserver/nginx/conf/jeepay.conf
server
{
listen 19217;
server_name localhost;
index index.html index.htm ;
root /home/jeepay/html/manager;
#解决vue刷新404问题
try_files $uri $uri/ /index.html;
location /api/
{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:9217;
}
}
server
{
listen 19218;
server_name localhost;
index index.html index.htm;
root /home/jeepay/html/merchant;
#解决vue刷新404问题
try_files $uri $uri/ /index.html;
location /api/
{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:9218;
# 启用支持websocket连接
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server
{
listen 19216;
server_name localhost;
index index.html index.htm;
root /home/jeepay/html/payment;
location /
{
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:9216;
}
}
上传build后的dist文件和jar包
创建目录,并将静态文件复制进来
mkdir -p /home/jeepay/html/cashier && mkdir -p /home/jeepay/html/manager && mkdir -p /home/jeepay/html/merchant
上传jar包
mkdir -p /home/jeepay/service/manager && mkdir -p /home/jeepay/service/merchant && mkdir -p /home/jeepay/service/payment
启动项目:
docker run --name jeepay-manager --net=host -it -d --restart=always -e TZ=Asia/Shanghai -v /home/jeepay/service:/home/jeepay/service -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtime openjdk:11-jdk-oracle sh -c 'cd /home/jeepay/service/manager && java -Dfile.encoding=UTF-8 -jar jeepay-manager.jar --spring.profiles.active=prod'
docker run --name jeepay-payment --net=host -it -d --restart=always -e TZ=Asia/Shanghai -v /home/jeepay/service:/home/jeepay/service -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtime openjdk:11-jdk-oracle sh -c 'cd /home/jeepay/service/payment && java -Dfile.encoding=UTF-8 -jar jeepay-payment.jar --spring.profiles.active=prod'
docker run --name jeepay-merchant --net=host -it -d --restart=always -e TZ=Asia/Shanghai -v /home/jeepay/service:/home/jeepay/service -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtime openjdk:11-jdk-oracle sh -c 'cd /home/jeepay/service/merchant && java -Dfile.encoding=UTF-8 -jar jeepay-merchant.jar --spring.profiles.active=prod'