# blowball-admin **Repository Path**: geqian618/blowball-admin ## Basic Information - **Project Name**: blowball-admin - **Description**: 基于 SpringBoot + SpringSecurity + MybatisPlus + Freemarker模板 +阿里云对象存储OSS + Vue2 + Element ui 后台权限管理系统,额外包含前后端代码生成器、聊天室功能等 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 12 - **Forks**: 4 - **Created**: 2023-12-07 - **Last Updated**: 2025-11-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: SpringBoot, Vue, 权限管理, 在线聊天, 前后端代码生成器 ## README

BlowballAdmin

![SpringBoot 2.4.2](https://img.shields.io/badge/SpringBoot-2.4.2-blue) ![SpringSecurity 2.4.2](https://img.shields.io/badge/SpringSecurity-2.4.2-blue) ![Vue 2](https://img.shields.io/badge/VUE-2-blue) ![elementui](https://img.shields.io/badge/ElementUI--blue) ![JWT](https://img.shields.io/badge/JWT--blue) ![Redis](https://img.shields.io/badge/Redis--blue) ![Guava](https://img.shields.io/badge/Guava--blue) ![caffeine](https://img.shields.io/badge/caffeine--blue) ![MySQL 8](https://img.shields.io/badge/MySQL-8-blue) ![MybatisPlus](https://img.shields.io/badge/MybatisPlus--blue) ![Freemarker](https://img.shields.io/badge/Freemarker--blue) ![阿里云对象存储OSS](https://img.shields.io/badge/阿里云OSS--blue) ![WebSocket](https://img.shields.io/badge/WebSocket--blue) ![ip2region](https://img.shields.io/badge/ip2region--blue) ## 技术栈 ### 后端 - 采用 SpringBoot 作为后端基础框架 - 采用 SpringSecurity + JWT 进行认证授权 - 采用 Redis 作为默认系统缓存,同时也支持切换 guava、caffeine 本地缓存作为系统缓存 - 采用 MySQL 数据库,MybatisPlus 作为 ORM 框架 - 采用 Freemarker 模板引擎技术生成前后端代码 - 采用阿里云对象存储OSS 作为默认存储访问文件资源,同时也支持切换本地存储访问文件资源 - 采用 WebSocket 实现简易聊天室功能 - 采用 ip2region 解析IP地址归属地 ### 前端 - 采用 Vue2 作为前端基础框架 - 采用 Element ui 作为前端组件库

## 项目架构 前后端分离的 B/S 架构

## 项目演示 1. 登录页面 ![输入图片说明](images/登录.png) 2. 首页 ![image-20230719013337074](images/首页.png) 3. 菜单管理 ![image-20230719013403179](images/菜单管理.png) 4. 用户管理 ![image-20230719013433699](images/用户管理.png) 5. 角色管理 ![image-20230719013433699](images/角色管理.png) 6. 简易聊天室 ![image-20230719013433699](images/简易聊天室.png) 7. 代码生成器 ![image-20230719013433699](images/代码生成器.png) 8. api 日志 ![image-20230719013433699](images/api日志.png) 9. 系统图标 ![image-20230719013433699](images/系统图标.png)

## 使用说明 ### 默认账号 - 账号:admin - 密码:123456

### 修改后端配置文件 1. 获取blowball-web下的sql文件,并执行sql文件 2. 更改数据源配置 ```properties spring.datasource.url=jdbc:mysql://localhost:3306/management_system?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username=root spring.datasource.password=root ``` 3. 更改 Redis 配置 ``` ################################# redis配置 ############################# #Redis服务器地址 spring.redis.host=192.168.119.100 #Redis服务器连接端口 spring.redis.port=6379 #使用的数据库索引,默认是0 spring.redis.database=0 #Redis服务器连接密码(默认为空) spring.redis.password=123456 #连接超时时间(毫秒) spring.redis.timeout=30000 #连接池最大连接数(使用负值表示没有限制) spring.redis.jedis.pool.max-active=3 #连接池最大阻塞等待时间(使用负值表示没有限制) spring.redis.jedis.pool.max-wait=-1 #连接池中的最大空闲连接 spring.redis.jedis.pool.max-idle=2 #连接池中的最小空闲连接 spring.redis.jedis.pool.min-idle=1 ``` 4. 更改阿里云对象存储OSS相关配置 ```properties ################################# 阿里云oss对象存储配置 ############################# alibaba.cloud.access-key=<你的> alibaba.cloud.secret-key=<你的> alibaba.cloud.oss.endpoint=<你的> alibaba.cloud.oss.bucket=<你的> alibaba.cloud.oss.file.expiration-days=30 ```

### 代码生成器使用 1. 数据源配置数据库下新建表 建表要求: ① 必须有主键或者唯一键(作为删除、更新的 where 条件) ② 建表时填写上表注释和列注释(用于生成项目名和生成表格的表头) ③ 列名命名使用下划线命名(项目中 MybatisPlus 配置中采用驼峰命名法) 2. 代码生成器页面导入创建的表 ![image-20230719013456536](images/导入表.png) 3. 点击生成代码,并重启前后端项目 ![image-20230719013456536](images/生成代码.png) 4. 生成项目列表中查看生成的项目 ![image-20230719013456536](images/生成页面.png) > 新增、修改表单组件不一定合适,按具体情况自行修改 5. 卸载代码(需要重新生成代码、不需要的模块) ![image-20230719013456536](images/卸载代码.png)

## 切换系统缓存 系统默认采用 Redis 作为系统缓存。为了方便一些简单的场景,也对本地缓存 guava、caffeine 进行了支持(**本地缓存不支持数据持久化**) 1. 排除默认的 redis 依赖,并导入 guava、caffeine 依赖 ```pom com.geqian blowball-cache 0.0.1-SNAPSHOT org.springframework.boot spring-boot-starter-data-redis com.github.ben-manes.caffeine caffeine ``` 2. 构建一个 guava 或 caffeine 缓存对象作为 bean 注入 Spring 容器 ```java @Configuration public class CaffeineCacheConfig { @Bean public LoadingCache loadingCache() { return Caffeine.newBuilder() //设置缓存中保存数据的最大量 .maximumSize(Integer.MAX_VALUE) //初始化缓存空间大小 .initialCapacity(100) //设置过期时间 .expireAfterAccess(60, TimeUnit.MINUTES) //构建Cache实例 .build(new CacheLoader() { @Override public Object load(String s) throws Exception { return null; } }); } } ``` 3. 注入缓存模板 SimpleCacheTemplate,进行缓存相关操作 ```java @Resource private SimpleCacheTemplate simpleCacheTemplate; ``` > 由于本地缓存功能有限,SimpleCacheTemplate 设计的缓存功能也相对比较简单,设置复杂的存储功能时,还是需要使用 RedisTemplate 之类的进行缓存操作

## 切换文件存储 默认使用阿里云 OSS 作为文件存储,为了方便一些简单场景使用,也对本地存储作了支持,步骤如下: 1. 注释阿里云 OSS 依赖 ```pom ``` 2. 更改本地缓存配置 ```properties ################################# 本地文件存储配置 ############################# # 上传文件本地保存位置 local-storage.file.save-path=${user.dir}\\blowball-web\\src\\main\\resources\\static\\images\\ # 访问本地资源文件请求url前缀 local-storage.file.request.url-prefix=http://localhost:8888/api/system/images/ ```