Skip to content

Commit

Permalink
[UPDATE]更新v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Exrick committed Aug 26, 2018
1 parent a07f447 commit 82c26ab
Show file tree
Hide file tree
Showing 78 changed files with 1,897 additions and 382 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

target/

maven/

xboot-logs/

*.iml

*.bak
222 changes: 73 additions & 149 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,191 +7,118 @@

> 作者大四作品 能力经验有限 如有错误欢迎指正 期待您的捐赠支持!
### [宣传视频](https://www.bilibili.com/video/av23121122/)
- 作者亲自制作 [点我观看](https://www.bilibili.com/video/av23121122/)
### 在线Demo
### 宣传视频
- [作者亲自制作XBoot文字快闪宣传视频](http://www.bilibili.com/av30284667)
- [作者亲自制作其他项目宣传视频](https://www.bilibili.com/video/av23121122/)
### [在线Demo](http://xboot.exrick.cn)
http://xboot.exrick.cn
### 前台为基于Vue+iView的独立项目请跳转至 [x-boot-front](https://github.com/Exrick/x-boot-front) 项目仓库查看
### 项目简介
- [x] 代码拥有详细注释 学习与实战的不错选择
- [x] 核心使用目前最新 SpringBoot 2.0.1.RELEASE
### 前台基于Vue+iView项目地址: [xboot-front](https://github.com/Exrick/xboot-front)
### 项目简介
- [x] 代码拥有详细注释 无复杂逻辑 核心使用 SpringBoot 2.0.4.RELEASE
- [x] JPA + Mybatis-Plus任意切换
- 项目持久层默认推荐使用JPA,更简单易上手,且OOP首先应满足面向对象的要求,而不是面向数据库。复杂业务逻辑需联表查询时可选择Mybatis-Plus写sql
- [x] AOP操作日志记录方式任意切换
- 默认使用数据库记录记录,可配置切换使用Elasticseach记录,使用Spring-Data-Elasticsearch简化开发
- [x] 极简代码生成
- 只需输入实体类名即可生成三层代码,自动创建数据库表
- [x] 操作日志记录方式任意切换Mysql或Elasticseach记录
- [x] 极简代码生成 只需输入类名和字段 自动创建数据库表
- [x] 支持社交账号、短信等多方式登录 不干涉原用户数据 实现第三方账号管理
- [x] 基于Websocket消息推送管理、基于Quartz定时任务管理
- [x] Actuator可视化数据监控
- [x] 后台提供分布式限流、同步锁、验证码等工具类 前端提供空白Vue模版
- [x] 为什么要前后端分离
- 都什么时代了还在用JQuery?
### 分支说明
- master:基于Redis的‘JWT’ (待提交)
- jwt:基于JWT,由于刷新token机制较麻烦,作者不推荐(待提交)
- oauth2:基于OAuth2协议(待开发)

![](https://i.loli.net/2018/07/24/5b56dfead395b.png)
### 截图预览

![](https://i.loli.net/2018/07/24/5b56e00daab72.png)
![QQ截图20180826163917.png](https://i.loli.net/2018/08/26/5b826868e2359.png)

![](https://i.loli.net/2018/07/24/5b56e06a81777.png)
![QQ截图20180826163956.png](https://i.loli.net/2018/08/26/5b8268c57d1e3.png)

![](https://i.loli.net/2018/07/24/5b56e08a4fb76.png)
![QQ截图20180826164058.png](https://i.loli.net/2018/08/26/5b8268d63d156.png)

![](https://i.loli.net/2018/07/24/5b56e0ac944a8.png)
![QQ截图20180826164129.png](https://i.loli.net/2018/08/26/5b8268dec28ee.png)

![](https://i.loli.net/2018/07/24/5b56e0ce6eb53.png)
![QQ截图20180826164144.png](https://i.loli.net/2018/08/26/5b8268e6a091f.png)

![QQ截图20180826164226.png](https://i.loli.net/2018/08/26/5b8268efab94a.png)

### [完整版截图细节展示](https://github.com/Exrick/x-boot/wiki/%E5%AE%8C%E6%95%B4%E7%89%88%E6%88%AA%E5%9B%BE%E7%BB%86%E8%8A%82%E5%B1%95%E7%A4%BA)

### 前端所用技术
- Vue 2.5.x、iView、iview-admin、iview-area、Vuex、Vue Router、ES6、webpack、axios、echarts、cookie等
- 前台为基于Vue+iView的独立项目请跳转至 [x-boot-front](https://github.com/Exrick/x-boot-front) 项目仓库查看
- Vue 2.5.x、Vue Cli 3.x、iView、iview-admin、iview-area、Vuex、Vue Router、ES6、webpack、axios、echarts、cookie等
- 前台为基于Vue+iView的独立项目请跳转至 [xboot-front](https://github.com/Exrick/xboot-front) 项目仓库查看
### 后端所用技术
##### 各框架依赖版本皆使用目前最新版本
- Spring Boot 2.0.1.RELEASE
- Spring Boot 2.0.4.RELEASE
- SpringMVC
- Spring Security
- [Spring Data JPA](https://docs.spring.io/spring-data/jpa/docs/2.0.6.RELEASE/reference/html/)
- [MyBatis-Plus](http://mp.baomidou.com)
- [Redis](https://github.com/Exrick/xmall/blob/master/study/Redis.md)
- [Elasticsearch](https://github.com/Exrick/xmall/blob/master/study/Elasticsearch.md):基于Lucene分布式搜索引擎
- [Druid](http://druid.io/):阿里高性能数据库连接池
- Json Web Token(JWT)
- [Druid](http://druid.io/):阿里高性能数据库连接池 [Druid配置官方中文文档](https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter)
- [Json Web Token(JWT)](https://jwt.io/)
- [Quartz](http://www.quartz-scheduler.org):定时任务
- [Beetl](http://ibeetl.com/guide/#beetl):模版引擎 代码生成使用
- [Hutool](http://hutool.mydoc.io/):Java工具包
- [Jasypt](https://github.com/ulisesbocchio/jasypt-spring-boot):配置文件加密(thymeleaf作者开发)
- [Swagger2](https://github.com/Exrick/xmall/blob/master/study/Swagger2.md):Api文档生成
- MySQL
- [Nginx](https://github.com/Exrick/xmall/blob/master/study/Nginx.md)
- [Maven](https://github.com/Exrick/xmall/blob/master/study/Maven.md)
- 第三方SDK
- 第三方SDK或服务
- [七牛云文件存储服务](https://developer.qiniu.com/kodo/sdk/1239/java)
- 第三方接口
- [Mob全国天气预报接口](http://api.mob.com/#/apiwiki/weather):需注册账号创建应用后申请填入AppKey后免费使用
- 完整版
- [Vaptcha人机验证码](https://www.vaptcha.com/)
- [阿里云短信服务](https://dysms.console.aliyun.com)
- 其它开发工具
- Lombok
- [Lombok](https://projectlombok.org/)
- ~~[JRebel](https://github.com/Exrick/xmall/blob/master/study/JRebel.md):开发热部署~~ 已无法免费使用 改回devtools
- [阿里JAVA开发规约插件](https://github.com/alibaba/p3c)

### 项目运行部署
### 本地运行部署
- 安装依赖并启动:[Redis](https://github.com/Exrick/xmall/blob/master/study/Redis.md)[Elasticsearch](https://github.com/Exrick/xmall/blob/master/study/Elasticsearch.md)(当配置使用ES记录日志时需要)
- [Maven安装和在IDEA中配置](https://github.com/Exrick/xmall/blob/master/study/Maven.md)
- 使用IDEA([破解/免费注册](http://idea.lanyus.com/)) 导入该Maven项目
- 修改配置文件 `application.yml` 相应配置,其中有详细注释
- 建议使用IDEA([破解/免费注册](http://idea.lanyus.com/)) 安装 `Lombok` 插件后导入该Maven项目 若未自动下载依赖请在根目录下执行 `mvn install` 命令
- MySQL数据库新建 `xboot` 数据库,配置文件已开启ddl自动生成表结构但无初始数据,请记得运行导入sql文件
- 配置第三方服务
- Mob接口 现在需要注册申请后使用 在 `cn.exrick.common.utils.IpInfoUtil` 中修改填入你的AppKey
- 七牛云对象存储 `cn.exrick.common.utils.QiniuUtil` 中修改填入你的配置
- 启动运行 `XbootApplication.java` 默认端口8888 访问接口文档 `http://localhost:8888/swagger-ui.html` 说明启动成功 管理员账密admin|123456
- 前台页面请启动基于Vue的 [xboot-front](https://github.com/Exrick/x-boot-front) 项目,并修改其接口代理配置

### 学习记录(更新中)
- 修改配置文件 `application.yml` 相应配置,其中有详细注释,所有配置只需在这里修改
- 编译器中启动运行 `XbootApplication.java` 或根目录下执行命令 `mvn spring-boot:run` 默认端口8888 访问接口文档 `http://localhost:8888/swagger-ui.html` 说明启动成功 管理员账密admin|123456
- 前台页面请启动基于Vue的 [xboot-front](https://github.com/Exrick/xboot-front) 项目,并修改其接口代理配置

### 开发指南及相关技术栈文档
- [项目基本配置和使用相关技术栈文档【必读】](https://github.com/Exrick/x-boot/wiki/%E9%A1%B9%E7%9B%AE%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AE%E5%92%8C%E4%BD%BF%E7%94%A8%E7%9B%B8%E5%85%B3%E6%8A%80%E6%9C%AF%E6%A0%88%E6%96%87%E6%A1%A3%E3%80%90%E5%BF%85%E8%AF%BB%E3%80%91)
- [如何使用XBoot后端在30秒内开发出增删改接口](https://github.com/Exrick/x-boot/wiki/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8XBoot%E5%90%8E%E7%AB%AF%E5%9C%A830%E7%A7%92%E5%86%85%E5%BC%80%E5%8F%91%E5%87%BA%E5%A2%9E%E5%88%A0%E6%94%B9%E6%8E%A5%E5%8F%A3)
- [具体X-Boot增删改文档示例](https://github.com/Exrick/x-boot/wiki/CRUD)
- 完整版
- [第三方社交账号登录配置](https://github.com/Exrick/x-boot/wiki/%E7%AC%AC%E4%B8%89%E6%96%B9%E7%A4%BE%E4%BA%A4%E8%B4%A6%E5%8F%B7%E7%99%BB%E5%BD%95%E9%85%8D%E7%BD%AE)
- [短信登录配置](https://github.com/Exrick/x-boot/wiki/%E7%9F%AD%E4%BF%A1%E7%99%BB%E5%BD%95%E9%85%8D%E7%BD%AE)
- - [Vaptcha人机验证码配置使用](https://github.com/Exrick/x-boot/wiki/vaptcha%E4%BA%BA%E6%9C%BA%E9%AA%8C%E8%AF%81%E7%A0%81%E9%85%8D%E7%BD%AE%E4%BD%BF%E7%94%A8)

### XBoot后端学习记录(更新中)
1.[Spring Boot 2.x 区别总结](https://github.com/Exrick/x-boot/wiki/SpringBoot2.x%E5%8C%BA%E5%88%AB%E6%80%BB%E7%BB%93)

2.Spring Security整合JWT

3.Spring Security动态数据库权限管理

### 开发指南及相关技术栈说明
- 项目使用 [Lombok](https://projectlombok.org/) 插件简化开发,请自行在编译器中安装,不安装会报错但不影响运行,常用注解说明:

- `@Data`:自动生成get、set等方法
- `@Slf4j`:日志打印可直接使用log.info()等

- 配置文件可使用Jasypt加密,可到 `cn.exrick.xboot.common` 包中找到 JasyptUtil 工具类生成加解密结果
```yaml
# 配置文件加密key
jasypt:
encryptor:
password: xboot

spring:
# 数据源
datasource:
# Jasypt加密 可到common-utils中找到JasyptUtil加解密工具类生成加密结果 格式为ENC(加密结果)
password: ENC(F4B0s6u9xcDw3V+P0qC4CA==)
```
- 操作日志使用ES或数据库记录配置 注解使用 `@SystemLog(description="操作日志名称")`
```yaml
xboot:
# 日志记录方式 true使用Elasticsearch记录 false记录至数据库中
logRecord:
es: false
```
- 接口相关
- 为方便前台配置代理,所有接口建议以统一路径例如“/xboot”开头
- 登录成功后前台请在返回的`result`字段中保存token

![](http://p77xsahe9.bkt.clouddn.com/18-6-6/65435347.jpg)
- 之后的请求中请在header或参数中添加该token即可

![](http://p77xsahe9.bkt.clouddn.com/18-6-6/95613949.jpg)
- 分布式限流(基于Redis令牌桶算法)
- 全局限流
```yaml
xboot:
# 全局限流
rateLimit:
enable: true
# 每1秒内
timeout: 1000
# 总限制100个请求
limit: 100
```
- 指定方法限流注解
```java
@RateLimiter(limit = 1, timeout = 5000)
```
- 支持多维度IP、uid等限流 详见代码
- 分布式同步锁(基于Redis)
```java
@Autowired
private RedisDistributedLockTemplate lockTemplate;
lockTemplate.execute("订单流水号", 5000, new Callback() {
@Override
public Object onGetLock() throws InterruptedException {
//TODO 获得锁后要做的事
log.info("生成订单流水号");
return null;
}
@Override
public Object onTimeout() throws InterruptedException {
//TODO 获得锁超时后要做的事
return null;
}
});
```
- 后台开发代码生成
- 代码生成方法在 `cn.exrick.xboot.generator` 包中的 `XbootGenerator.java` 工具类,修改好生成类配置后运行主函数main方法即可生成三层相关代码,别忘了在实体类中添加相关字段,运行项目后将自动生成数据库表

- 增删改查(CRUD)
- JPA与Mybatis-Plus随意切换
- 不想写sql?[Spring Data JPA](https://docs.spring.io/spring-data/jpa/docs/2.0.6.RELEASE/reference/html/#jpa.query-methods.query-creation) 了解一下

[具体x-boot增删改文档示例](https://github.com/Exrick/x-boot/wiki/CRUD)
- 复杂业务逻辑JPA联表太蛋疼?[MyBatis-Plus](http://mp.baomidou.com) 这就不用了解了吧
- JPA与MybatisPlus同时使用时需注意实体类注解区别,更多请见官方文档,常用注解区别:
```java
//表名
JPA: @Table(name = "t_user")
MP: @TableName("t_user")
//排除非表字段
JPA: @Transient
MP: @TableField(exist=false)
```
- Spring缓存注解
```java
@CacheConfig(cacheNames = "user")
public interface UserService extends XbootBaseService<User,String> {
@Cacheable(key = "#username")
User findByUsername(String username);
}
```
- 删除刷新注解 `@CacheEvict(key = "#u.username")` 手动删除刷新缓存时注意key为:`user::username`
- Spring Security官方推荐权限管理:`@PreAuthorize("hasRole('ADMIN')")`
- Spring定时:`@Scheduled(cron="cron表达式")`
- Spring异步:`@Async`

等自行了解
3.Spring Security实现动态数据库权限管理

4.[Spring Boot 2.x整合Quartz](https://github.com/Exrick/x-boot/wiki/Spring-Boot-2.x%E6%95%B4%E5%90%88Quartz)

5.[基于Websocket实现发送消息后右上角消息图标红点实时显示](https://github.com/Exrick/x-boot/wiki/%E5%9F%BA%E4%BA%8EWebsocket%E5%AE%9E%E7%8E%B0%E5%8F%91%E9%80%81%E6%B6%88%E6%81%AF%E5%90%8E%E5%8F%B3%E4%B8%8A%E8%A7%92%E6%B6%88%E6%81%AF%E5%9B%BE%E6%A0%87%E7%BA%A2%E7%82%B9%E5%AE%9E%E6%97%B6%E6%98%BE%E7%A4%BA)

### Docker下后端集群部署(更新中)

> 前端集群部署请跳转至[xboot-front](https://github.com/Exrick/xboot-front)项目查看
1.Docker安装与常用命令

2.基于PXC架构Mysql数据库集群搭建

3.Redis集群搭建

4.Elasticsearch集群搭建

5.XBoot后端集群部署

### 分布式扩展

### 作者其他项目推荐
- [XPay个人免签收款支付系统v1.2](https://github.com/Exrick/xpay)

Expand All @@ -211,7 +138,4 @@ xboot:
- QQ交流群 `475743731(付费)`,可获取各项目详细图文文档、疑问解答 [![](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=7b60cec12ba93ebed7568b0a63f22e6e034c0d1df33125ac43ed753342ec6ce7)
- 免费交流群 `562962309` [![](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=52f6003e230b26addeed0ba6cf343fcf3ba5d97829d17f5b8fa5b151dba7e842)
- 作者博客:[http://blog.exrick.cn](http://blog.exrick.cn)
### 捐赠
![](http://p77xsahe9.bkt.clouddn.com/18-7-20/54731550.jpg)

![](http://p77xsahe9.bkt.clouddn.com/18-6-28/32845239.jpg)
### [捐赠](http://xpay.exrick.cn/pay)
Loading

0 comments on commit 82c26ab

Please sign in to comment.