Skip to content

Commit 83bf869

Browse files
author
sqmax
committed
modify readme.md
1 parent 1dda924 commit 83bf869

File tree

4 files changed

+62
-16
lines changed

4 files changed

+62
-16
lines changed

README.md

+57-12
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,68 @@
33
* 项目整体介绍。[http://www.sqmax.top/springboot-project/](http://www.sqmax.top/springboot-project/)
44
* 项目中设计的知识细节及难点以博客的形式整理在Wiki里。[Wiki](https://github.com/sqmax/springboot-project/wiki)
55

6-
## 使用方式
7-
8-
0. 安装环境:redis,mysql,maven。
9-
1. 使用命令`git clone https://github.com/sqmax/springboot-project.git`克隆到本地。
10-
2. 在IDEA里。File->open...,然后选择项目文件夹。
11-
3. 在IDEA里,安装lombok插件。File->Settings...->Plugin,搜索lombok,安装。
12-
4. 运行数据库脚本sqmax.sql(注意这里使用的是MySQL5.7,不同的数据库版本语法可能有些差异)。
13-
5. 工程资源路径下的application.yml是Spring Boot的配置文件,修改里面的iP为自己的ip。
14-
6. 以SellApplication类为Main class来运行项目(Spring Boot就是这样,可以运行一个含main方法的类来启动一个Web项目)。
15-
7. 浏览器访问:`http://localhost:8080/sell/seller/order/list`,就可以来到商家管理界面。
6+
## 安装环境:
7+
1. MySQL。可以下载这个在线安装器:[https://dev.mysql.com/downloads/windows/installer/8.0.html](https://dev.mysql.com/downloads/windows/installer/8.0.html),安装MySQL社区版。
8+
2. Redis。我在官网上没有找到redis的window版的下载链接,是到github下载的。下载地址:[https://github.com/servicestack/redis-windows/tree/master/downloads](https://github.com/servicestack/redis-windows/tree/master/downloads),下载最新版redis-latest.zip,解压即可。可以在解压后的根目录下看到redis-server.exe文件,双击即可启动redis服务器。
9+
3. Nginx。下载地址:[http://nginx.org/en/download.html](http://nginx.org/en/download.html)。下载的zip压缩包,解压后根目录下有nginx.exe文件,双击即可启动nginx服务器。
10+
4. IDEA。下载地址:[https://www.jetbrains.com/idea/download/#section=windows](https://www.jetbrains.com/idea/download/#section=windows)
11+
4. JDK1.8+、maven、IDEA。这些都是java开发的常用工具,就不做解释。
12+
13+
>注:IDEA不要下载Community版,下载Ultimate版,付费,但网上可以很容易找到注册码。
14+
MySQL数据库我用的是5.7.21的版本,本项目的建表语句好像不兼容5.6的版本,建议也装5.7以上的版本。
15+
推荐一个比较好用的MySQL客户端图形界面:[Navicat for MySQL](https://www.navicat.com/en/download/navicat-for-mysql),收费,有30天使用期。也可以下载低版本的,网上可以找到注册码。
16+
Redis客户端图形界面:[Redis Desktop Manager](https://redisdesktop.com/download),免费。Maven远程最好改为阿里云仓库,网上有修改方式,很简单。
17+
18+
## 运行方式:
19+
1. 使用命令`git clone https://github.com/sqmax/springboot-project.git`将项目克隆到本地。
20+
2. 将项目导入IDEA。在IDEA里,File->open...,然后选择项目文件夹(springboot-project)。如果是初次使用spring boot,这个过程可能会有点久,需要下载许多依赖的jar包。
21+
4. 为IDEA安装lombok插件。在IDEA里,File->Settings...->Plugin,搜索lombok,安装。项目wiki介绍日志时有提到为什么安装这个插件。
22+
3. 项目的配置文件在resources目录下,application.yml文件。修改MySQL数据库连接信息。我的数据库账号密码分别为root,123456,改为你的即可。
23+
4. 在MySQL数据库终端运行建表语句的sql脚本(或者使用刚下载的Navicat for MySQL图形化工具),本项目的建表语句为项目根路径下的sqmax.sql
24+
5. 启动redis。在刚才解压的Redis根目录下,双击redis-cli.exe即可运行redis服务。
25+
6. 最后就可以启动项目了。在IDEA里以Spring Boot的方式运行SellApplication这个主类。可以看到这和我们传统的web项目启动的方式不一样,我们没有配置tomcat等之类的服务器,因为Spring Boot已将服务器引入起步依赖中了。
26+
7. 经过以上步骤,我们的项目应该已经可以启动起来了。访问:`http://127.0.0.1:8080/sell/seller/product/list`,即可来到我们的卖家端的商家管理系统界面。效果如下:
27+
28+
![](http://p91462zt8.bkt.clouddn.com/PC.PNG)
29+
30+
## 访问买家的前端界面
31+
1. 项目的前后端是完全分离的,买家端前端的代码在另一个仓库,使用`git clone https://github.com/sqmax/vuejs-project.git`下载前端项目,其中项目根路径(vuejs-project)下的dist目录就是前端编译后的代码。
32+
2. 修改nginx的配置文件,让nginx可以找到前端代码。在nginx根目录下的conf目录下有一个nginx.conf文件,它就是我们要修改的配置文件,其中有下面一段:
33+
34+
```
35+
server {
36+
listen 80;
37+
server_name localhost;
38+
39+
#charset koi8-r;
40+
41+
#access_log logs/host.access.log main;
42+
43+
location / {
44+
root F:\vuejs-project\dist; #前端资源路径
45+
index index.html index.htm;
46+
}
47+
location /sell/ {
48+
proxy_pass http://127.0.0.1:8080/sell/;
49+
}
50+
51+
```
52+
53+
上面的`F:\vuejs-project\dist;`该为你刚才git clone下的前端项目的dist目录。
54+
55+
4. 双击nginx.exe启动nginx服务器,如果已启动过,命令行进入nginx的根目录,输入`nginx -s reload`重启nginx服务器。
56+
5. 浏览器访问:`http://127.0.0.1/#/order/`,这是会出现空白界面,按F2打开浏览器的开发者工具,在浏览器的控制台输入`document.cookie='abc123'`
57+
向该域名下添加cookie。再次访问:`http://127.0.0.1`,这时就可以访问到前端界面了。如下:
58+
59+
![](http://p91462zt8.bkt.clouddn.com/weixin.PNG)
1660
8. 对于手机端微信公众号内访问,还要使用到内网穿透工具,由于微信里不能直接访问ip地址,还要购买域名,还涉及到挺复杂的微信调试。这里就不再介绍。可以使用postman这个工具模拟微信点餐下单。访问接口参见controller包下以Buyer开头的类。
1761
9. 如果想查看微信端的访问效果,可以在微信客户端访问这个链接:`http://sell.springboot.cn/`。(注意这是师兄上线的项目演示)
1862
如果使用电脑访问的话,可以首先访问:[http://sell.springboot.cn/#/order/](http://sell.springboot.cn/#/order/)
19-
然后,按F12打开浏览器的开发者工具,点击控制台,在控制台输入:document.cookie='openid=abc123';
63+
然后,`F12`打开浏览器的开发者工具,点击控制台,在控制台输入:`document.cookie='openid=abc123'`
2064
然后重新访问:[http://sell.springboot.cn](http://sell.springboot.cn),就可以看到前端效果了。
2165

2266

2367
>关于IDEA。对于使用Eclipse的伙伴,可以尝试一下IDEA。我做这个项目也是第一次使用IDEA,感觉非常智能好用,可以参见一下这个仓库:[https://github.com/judasn/IntelliJ-IDEA-Tutorial](https://github.com/judasn/IntelliJ-IDEA-Tutorial),非常好的IDEA使用教程。
2468
25-
>上面的使用方式是刚做完项目写的理解还不是太深刻,有些简略,可能有些问题,而且前端vue.js项目代码还没有放上去,这几天在进一步整理,到时会把前端vue.js代码都放上去。-2018.06.15
69+
>关于前端。前端的vue.js项目,我也没有学习,我只是拿来做演示,有兴趣的可以到慕课网学习。
70+

src/main/java/com/imooc/handler/SellerExceptionHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ public ModelAndView handlerAuthorizeException(){
3232
.concat("/sell/seller/login"));
3333
}
3434

35-
3635
@ExceptionHandler(value = SellException.class)
3736
@ResponseBody
3837
public ResultVO handlerSellerException(SellException e){
3938
return ResultVOUtil.error(e.getCode(),e.getMessage());
4039
}
40+
4141
@ExceptionHandler(value = ResponseBankException.class)
4242
@ResponseStatus(HttpStatus.FORBIDDEN)
4343
public void handleResponseBankException(){

src/main/resources/application.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ spring:
99
jackson:
1010
default-property-inclusion: non_null
1111
redis:
12-
host: 192.168.0.104
12+
host: 127.0.0.1
1313
port: 6379
1414
server:
1515
context-path: /sell
@@ -21,6 +21,7 @@ server:
2121
# level:
2222
# com.imooc.LoggerTest: debug
2323

24+
# 下面是微信相关的配置
2425
wechat:
2526
# mpAppId: wxdcf91e9f784bfad0
2627
# mpAppSecret: c467c06d98a2447f5ddef6ca8f47f268 #测试号appId,appSecret

src/main/resources/static/api/seller.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"errno": 0,
33
"data": {
4-
"name": "粥品香坊(回龙观)",
5-
"description": "蜂鸟专送",
4+
"name": "星海美食",
5+
"description": "美团专送",
66
"deliveryTime": 38,
77
"score": 4.2,
88
"serviceScore": 4.1,

0 commit comments

Comments
 (0)