文章创建日期 2021-03-31
希望此文章,可以为使用Litemall项目的开发人员起到一定的帮助作用
litemal项目gitHub地址:
https://github.com/linlinjava/litemall.git star 15.6K
开发参考文档:https://linlinjava.gitbook.io/litemall/
配置最小开发环境:
数据库依次导入litemall-db/sql下的数据库文件
- litemall_schema.sql
- litemall_table.sql
- litemall_data.sql
1.下载项目到自己电脑上:
使用git bash操作
git clone https://github.com/linlinjava/litemall.git
项目目录结构如图所示
本地运行
通过IDEA运行
修改配置文件
- litemall-core 模块下 resources 下的 application-core.yml
litemall:
# 开发者应该设置成自己的wx相关信息
wx: ## 支付使用必须配置
app-id: wx8ac001 ###小程序的 appID
app-secret: a0e5f5446b5fd358c9f8eb5d8237e064 ### 小程序的密钥
mch-id: 16050010 ### 商户配置
mch-key: 8jP ### 商户配置
notify-url: https://localhost:8080/wx/order/pay-notify ###回调配置
# 商户证书文件路径
# 请参考“商户证书”一节 https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=4_3
key-path: /home/app/wx_cert
#通知相关配置
notify:
mail:
# 邮件通知配置,邮箱一般用于接收业务通知例如收到新的订单,sendto 定义邮件接收者,通常为商城运营人员
enable: true
host: smtp.163.com
username: gyf@163.com
password:
sendfrom: gyf@163.com
sendto: gyf@163.com
port: 465
# 短消息模版通知配置
# 短信息用于通知客户,例如发货短信通知,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
sms:
enable: true
# 如果是腾讯云短信,则设置active的值tencent
# 如果是阿里云短信,则设置active的值aliyun
active: tencent
sign: XXXX
template:
- name: paySucceed
templateId: 795879
- name: captcha
templateId: 795730
- name: ship
templateId: 795967
- name: refund
templateId: 795976
tencent:
appid: 1400457993
appkey:
aliyun:
regionId: xxx
accessKeyId: xxx
accessKeySecret: xxx
# 快鸟物流查询配置
express:
enable: true
appId: "XXXXXX"
appKey: "97bc9cb8-ee8c-4851-a311-76813f3064e5"
vendors:
- code: "ZTO"
name: "中通快递"
- code: "YTO"
name: "圆通速递"
- code: "YD"
name: "韵达速递"
- code: "YZPY"
name: "邮政快递包裹"
- code: "EMS"
name: "EMS"
- code: "DBL"
name: "德邦快递"
- code: "FAST"
name: "快捷快递"
- code: "ZJS"
name: "宅急送"
- code: "TNT"
name: "TNT快递"
- code: "UPS"
name: "UPS"
- code: "DHL"
name: "DHL"
- code: "FEDEX"
name: "FEDEX联邦(国内件)"
- code: "FEDEX_GJ"
name: "FEDEX联邦(国际件)"
# 对象存储配置
storage:
# 当前工作的对象存储模式,分别是local、aliyun、tencent、qiniu
active: local
# 本地对象存储配置信息
local:
storagePath: storage
# 这个地方应该是wx模块的WxStorageController的fetch方法对应的地址
address: http://localhost:8080/wx/storage/fetch/
# 阿里云对象存储配置信息
aliyun:
endpoint: oss-cn-shenzhen.aliyuncs.com
accessKeyId: 111111
accessKeySecret: xxxxxx
bucketName: litemall
# 腾讯对象存储配置信息
# 请参考 https://cloud.tencent.com/document/product/436/6249
tencent:
secretId:
secretKey:
region:
bucketName:
# 七牛云对象存储配置信息
qiniu:
endpoint: http://pd5cb6ulu.bkt.clouddn.com
accessKey: 111111
secretKey: xxxxxx
bucketName: litemall
- 修改数据源配置 litemall-db/src/main/resources/application-db.yml
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
spring:
datasource:
druid: ## 改成自己的连接配置
url: jdbc:mysql://host:prot/litemall?&allowPublicKeyRetrieval=true&verifyServerCertificate=false&useSSL=false
driver-class-name: com.mysql.jdbc.Driver
username: litemall
password:
initial-size: 10
max-active: 50
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
validation-query: SELECT 1 FROM DUAL
test-on-borrow: false
test-on-return: false
test-while-idle: true
time-between-eviction-runs-millis: 60000
webStatFilter:
enabled: true
statViewServlet:
enabled: false
filter:
stat:
enabled: false
- 使用maven install项目
在 litemall/pom.xml 下执行 maven 命令
mvn install -Dmaven.test.skip=true
代表mvn install成功
通过IDEA启动项目
执行litemall-all 项目的main函数,启动成功后,则代表后端所有项目接口发布成功
后端项目端口默认为 8080
通过java -jar 命令运行
cd litemall
mvn install
mvn clean package
java -Dfile.encoding=UTF-8 -jar litemall-all/target/litemall-all-0.1.0-exec.jar
启动管理后台前端
安装node.js 和npm
请参考 doc
命令行
npm install -g cnpm --registry=https://registry.npm.taobao.org
cd litemall/litemall-admin
cnpm install
cnpm run dev
项目配置结构
- 管理后台前端,即litemall-admin模块,配置文件在litemall-admin中,存在三个配置文件
env.development
,env.deployment
和.env.production
。这里面配置信息都是一样,最主要的配置是VUE_APP_BASE_API
,即管理后台的服务根地址。- 开发阶段,开发者运行命令
cnpm run dev
,这里就会采用env.development
配置文件; - 部署阶段,当开发者运行命令
cnpm run build:dep
,这里就会采用env.deployment
配置文件; - 上线阶段,当开发者运行命令
cnpm run build:prod
,这里就会采用.env.production
配置文件。
- 开发阶段,开发者运行命令
- 小商场前端,即litemall-wx模块,配置文件是
litemall-wx/project.config.json
和litemall-wx/api.js
。 这里面最主要的配置信息是project.config.json
中的appid
,开发者需要设置自己申请的appid; 以及apis.js
中的WxApiRoot
,即小商场服务根地址
项目api模块 可以单独部署,通过代理服务器进行分发; 也可以集中部署 ,通过 all 工程