16 Star 94 Fork 24

hsshy / beam-parent

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
LGPL-3.0

beam-parent

管理系统演示地址(演示账号只提供界面展示,没有按钮权限即看不到按钮)

http://www.hsshy.com/#/login 演示账户:test 123456

介绍

项目介绍

  • 基于SpringBoot 2,一款快速开发的脚手架。
  • beam-admin:后台管理系统,前后端分离。页面在当前目录html/beam-manage-system下(Vue+element-ui)。
  • beam-api:用于快速构建接口型项目,包含token机制、post签名机制保证接口安全性。swagger访问地址:http://localhost:8081/swagger-ui/index.html#/。
  • 其他相关模块作用请看底下项目结构。
  • 有配套的代码生成器可供使用。
  • 基础模块:
    • 用户管理
    • 角色管理
    • 菜单管理
    • 部门管理
    • 定时任务
    • 字典管理
    • 登陆日志
    • 业务日志
  • 项目特点:
    • 持久层:mybatis持久化,使用MyBatis-Plus优化,减少sql开发量;Transtraction注解事务。
    • 使用SpringBoot自动装配,配置简便,开箱即用
    • 将service、dao、entity接口提为公共模块,接口模块与后台管理系统可共用。不共用,只需将相应的模块放在对应的子工程中
    • 接口模块已添加拦截和post请求签名,提高了安全性
    • 后端可使用map+wrapper返回方式返回字段的字典值,无需再前端一一对应字典值所对应的中文名称
    • 前后端分离
    • 异步插入日志
    • 实现了用户角色菜单权限动态配置,精确到按钮级别
    • 线上日志分类
    • 图片存储(七牛云)(注册地址:https://portal.qiniu.com/signup?code=1h8cpibemhb9u)
    • 定时任务:Quartz,已搭建成界面化方式,配置即可使用
    • 工具类:excel导入导出,汉字转拼音,字符串工具类,数字工具类,发送邮件,redis工具类,MD5加密,HTTP工具类,防注入工具类,i18n 国际化多语言工具等等。
    • 动态数据源模块抽离封装,即插即用
    • 集群session共享

技术选型

  • 核心框架:Spring Boot 2.2.2
  • 安全框架:Apache Shiro 1.4
  • 视图框架:Spring MVC 5.0
  • 持久层框架:MyBatis,使用了增强工具MyBatis-Plus(https://mybatis.plus/)
  • 定时器:Quartz 2.3
  • 数据库连接池:hikari
  • 后台管理系统前端:Vue2.x+element-ui (可更换主题颜色)
  • 缓存:Redis
  • 图片存储:七牛云(七牛云注册便有10G免费空间,注册地址:https://portal.qiniu.com/signup?code=1h8cpibemhb9u)。

项目结构

beam-parent
├─beam-common     公共模块

├─beam-web  公用实体类、dao、service

├─beam-dynamic-datasource  动态数据源模块(按需引入)

├─beam-quartz  定时任务模块(按需引入)不需要此模块可将quartz开头的表全部删除

├─beam-admin     管理后台系统(独立的与beam-rest无关联)
│        └─resources 
│           ├─application.yml  配置文件
│           ├─logback-spring.xml  日志配置文件

├─beam-api  API接口模块 (post请求签名、token)


├─html/beam-manager-system 前端代码

├─doc  数据库sql文件


软件需求

  • IntelliJ IDEA
  • JetBrains WebStorm
  • JDK1.8
  • MySQL5.5+
  • Maven3.0+
  • Redis
  • lombok插件

运行流程

初始化数据库

创建数据库beam,运行doc下的脚本beam.sql,若需要使用quartz定时任务,执行quartz.sql。不需要可不执行。

指定运行环境

image.png image.png

动态数据源测试方法
  • 打开beam-rest模块pom文件的注解
  • 新建数据库test,将beam数据库的sys_config同步到测试数据库test,修改不同数据
  • 打开TestController的注释,运行项目,环境选择test,即可进行测试。

部署流程

软件安装(Linux)
后端:
  • 服务器选的是阿里云(注册地址:https://chuangke.aliyun.com/invite?userCode=647hkjjy)
  • 打包:package -Dmaven.test.skip
  • 运行:nohup java -jar xxx.jar --spring.profiles.active=prod >/dev/null 2>&1 &
  • 查看运行日志:tail -f beam-admin-logs/log_total.log
  • doc目录下提供运行脚本,脚本与jar包放在同级目录下即可。chmod 777 deploy.sh(添加读写执行权限),脚本运行报错(执行dos2unix deploy.sh,window环境下与Linux环境下文本格式有所不同)
docker部署
  • 安装docker https://www.jianshu.com/p/270020e5b313
  • 打包:package -Dmaven.test.skip
  • 将项目中的Dockerfile与jar包放在同个目录下
  • 构建镜像:docker build -t beam-admin .
  • 运行:docker run -d -p 8080:8080 -v /home/beam/console/beam-admin-logs:/beam-admin/beam-admin-logs --net=host --name beam-admin beam-admin:latest
  • 挂载日志的目录自行修改
  • --net=host指定容器与宿主机公用网络
docker-compose部署
  • 安装docker-compose https://www.jianshu.com/p/e1cbd566b0ab
  • 打包:package -Dmaven.test.skip
  • 根据docker-compose.yml和Dockerfile里的路径建立相应的文件夹,并把文件放进去
  • 在docker-compose.yml执行docker-compose build构建镜像,再执行docker-compose up -d
前端(这边是用nginx进行部署):
  • 打包:npm run build
  • 上传:进入dist文件夹,scp -r * root@xx.xx.xx.xx:/etc/nginx/html/beam-manage-system/
  • 给文件夹设置权限。
  • nginx配置请参考doc下的beam.conf文件,可直接传到服务器下的nginx/conf.d/下进行使用,记得删除默认的default.conf文件,重启nginx。

部署可能出现的问题

  • 出现表不存在(定时任务相关的表改成大写或者将数据库改成大小写不敏感)
  • 脚本运行报错(执行dos2unix deploy.sh,window环境下与Linux环境下文本格式有所不同)
  • Nginx 403:给前端文件夹设置可读写的权限。
  • Nginx 404:后台管理系统接口要与前端对应上,详情看doc下beam.conf的配置。
  • 使用docker部署,quartz在容器可能会获取不到hostname(d),java.net.UnknownHostException: iZwz9dxalf5enusvfvarnsZ: iZwz9dxalf5enusvfvarnsZ: 未知的名称或服务:vim /etc/hosts把容器主机名加进去 例如127.0.0.1 iZwz9dxalf5enusvfvarnsZ
  • 使用docker部署,连不上宿主机数据库:--net=host指定容器与宿主机公用网络

Post请求签名方法

方法一,通过拦截器

  • 1. 与前端约定key值,若请求的content­type 为 application/json,则使用与方法二一样的签名方式。需要额外定义一个过滤器,来解决post请求body输入流可多次读取的问题。
  • 2、若请求的content­type 为 application/x-www-form-urlencoded,则按照key升续排序,然后拼接上key=secret做MD5加密。

方法二,通过HttpMessageConverter实现

  • 1. 与前端约定key值,请求的content­type 为 application/json
  • 2. 请求的参数 固定格式为 {“object”:”数据“,”sign”:”签名“} 
  • 3. 所有请求的json参数对象进行base64编码得到的值 暂且叫做object , 而签名是 object+key 然后进行md5编码做为sign值。

常见问题

  • 上传图片失败,请修改sys_config中的七牛云配置,改为自己的七牛云配置。(七牛云注册便有10G免费空间,注册地址:https://portal.qiniu.com/signup?code=1h8cpibemhb9u)。
  • 提示账户验证失败,检查是否安装Redis,以及用户名密码是否正确。
  • set、get报红,请安装Lombok插件。详情请参照软件需求。

代码生成器

https://gitee.com/hsshy/beam-generator

还有问题

  • QQ群:750416471
  • 个人微信(base64):aHM0NTcwMzA1OTk=
GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

简介

暂无描述 展开 收起
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/hsshy/beam-parent.git
git@gitee.com:hsshy/beam-parent.git
hsshy
beam-parent
beam-parent
master

搜索帮助