# ssm **Repository Path**: Jiangmuci/ssm ## Basic Information - **Project Name**: ssm - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-02-26 - **Last Updated**: 2025-09-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 工具 梯子:https://tzdaohang.com/ 内网穿透工具:网云穿 https://www.xiaomy.net/download # 微人事参考视频 ## 码提交地址 前端 https://gitee.com/qijin-fenghua/vue-shop-front-end.git ![image-20240311155409971](readme.assets/image-20240311155409971.png) 后端 https://gitee.com/chen-luoping/ssm.git 代码地址: https://gitee.com/lenve/vhr?_from=gitee_search 部署概述版: https://www.bilibili.com/video/BV1Vt4y197Ge/?spm_id_from=333.337.search-card.all.click&vd_source=63e20212760fec307590b389a0f0d48e 详细讲解版: https://www.bilibili.com/video/BV1LF4m1L74g/?spm_id_from=333.337.search-card.all.click 运行时:后端代码不用执行sql ## 项目介绍 微人事是一个前后端分离的人力资源管理系统,项目采用 SpringBoot+Vue 开发,项目加入常见的企业级应用所涉及到的技术点,例如 Redis、RabbitMQ 等。 - 项目地址:[https://github.com/lenve/vhr](https://github.com/lenve/vhr) - [项目部署视频教程(旧版)](https://mp.weixin.qq.com/s/qN01Le434FWom0c3jqiQmA) - [项目部署视频教程(新版)](https://mp.weixin.qq.com/s/dcJv6BIVFPnokI8nBf4IrQ) - [项目其他相关资料](./README_zh.md) ### 项目技术栈 #### 后端技术栈 1. Spring Boot 2. Spring Security 3. MyBatis 4. MySQL 5. Redis 6. RabbitMQ 7. Spring Cache 8. WebSocket 9. ... #### 前端技术栈 1. Vue 2. ElementUI 3. axios 4. vue-router 5. Vuex 6. WebSocket 7. vue-cli4 8. ... ### 项目效果图 首先,不同的用户在登录成功之后,根据不同的角色,会看到不同的系统菜单,完整菜单如下: ![p278](https://raw.githubusercontent.com/wiki/lenve/vhr/doc/p278.png) 不同用户登录上来之后,可能看到的会有差异,如下: ![p279](https://raw.githubusercontent.com/wiki/lenve/vhr/doc/p279.png) 每个用户的角色是由系统管理员进行分配的,系统管理员给用户分配角色的页面如下: ![p280](https://raw.githubusercontent.com/wiki/lenve/vhr/doc/p280.png) 系统管理员也可以管理不同角色可以操作的资源,页面如下: ![p281](https://raw.githubusercontent.com/wiki/lenve/vhr/doc/p281.png) ## 快速部署 1. clone 项目到本地 `git@github.com:lenve/vhr.git` 2. 数据库脚本使用 Flyway 管理,**不需要手动导入数据库脚本**,只需要提前在本地 MySQL 中创建一个空的数据库 vhr,并修改项目中关于数据的配置(resources 目录下的 application.properties 文件中)即可 3. 提前准备好 Redis,在 项目的 application.properties 文件中,将 Redis 配置改为自己的 4. 提前准备好 RabbitMQ,在项目的 application.properties 文件中将 RabbitMQ 的配置改为自己的(**注意,RabbitMQ 需要分别修改 mailserver 和 vhrserver 的配置文件**) 5. 在 IntelliJ IDEA 中打开 vhr 项目,启动 mailserver 模块 6. 运行 vhrserver 中的 vhr-web 模块 **OK,至此,服务端就启动成功了,此时我们直接在地址栏输入 `http://localhost:8081/index.html` 即可访问我们的项目,如果要做二次开发,请继续看第七、八步。** 7. 进入到vuehr目录中,在命令行依次输入如下命令: ``` #node版本:v14.21.3 #删除 node_modules,删除package-lock.js #配置淘宝镜像地址 npm config set registry https://registry.npmmirror.com/ #或镜像地址 npm install --registry=https://registry.npm.taobao.org重新拉取依赖 # 安装依赖 npm install # 在 localhost:8080 启动项目 npm run serve ``` 由于我在 vuehr 项目中已经配置了端口转发,将数据转发到 Spring Boot 上,因此项目启动之后,在浏览器中输入 `http://localhost:8080` 就可以访问我们的前端项目了,所有的请求通过端口转发将数据传到 Spring Boot 中(注意此时不要关闭 Sprin gBoot 项目)。 8. 最后可以用 WebStorm 等工具打开 vuehr 项目,继续开发,开发完成后,当项目要上线时,依然进入到 vuehr 目录,然后执行如下命令: ``` npm run build ``` 该命令执行成功之后,vuehr 目录下生成一个 dist 文件夹,将该文件夹中的两个文件 static 和 index.html 拷贝到 Spring Boot 项目中 resources/static/ 目录下,然后就可以像第 6 步那样直接访问了(关于前后端分离部署,大家也可以参考这个[使用 Nginx 部署前后端分离项目,解决跨域问题](https://mp.weixin.qq.com/s/C7PIck3SIPPTcA3NX3ELoQ))。 **步骤 7 中需要大家对 NodeJS、NPM 等有一定的使用经验,不熟悉的小伙伴可以先自行搜索学习下,推荐 [Vue 官方教程](https://cn.vuejs.org/v2/guide/)。** ## 后端 启动redis,启动mysql,创建vhr数据库,启动服务 ![image-20240311170257028](README.assets/image-20240311170257028.png) ## 文档 文档是对项目开发过程中遇到的一些问题的详细记录,主要是为了帮助没有基础的小伙伴快速理解这个项目。 1. [权限数据库设计](https://github.com/lenve/vhr/wiki/1.%E6%9D%83%E9%99%90%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AE%BE%E8%AE%A1) 2. [服务端环境搭建](https://github.com/lenve/vhr/wiki/2.%E6%9C%8D%E5%8A%A1%E7%AB%AF%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA) 3. [动态处理角色和资源的关系](https://github.com/lenve/vhr/wiki/3.%E5%8A%A8%E6%80%81%E5%A4%84%E7%90%86%E8%A7%92%E8%89%B2%E5%92%8C%E8%B5%84%E6%BA%90%E7%9A%84%E5%85%B3%E7%B3%BB) 4. [密码加密并加盐](https://github.com/lenve/vhr/wiki/4.%E5%AF%86%E7%A0%81%E5%8A%A0%E5%AF%86%E5%B9%B6%E5%8A%A0%E7%9B%90) 5. [服务端异常的统一处理](https://github.com/lenve/vhr/wiki/5.%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%BC%82%E5%B8%B8%E7%9A%84%E7%BB%9F%E4%B8%80%E5%A4%84%E7%90%86) 6. [axios 请求封装,请求异常统一处理](https://github.com/lenve/vhr/wiki/6.axios%E8%AF%B7%E6%B1%82%E5%B0%81%E8%A3%85,%E8%AF%B7%E6%B1%82%E5%BC%82%E5%B8%B8%E7%BB%9F%E4%B8%80%E5%A4%84%E7%90%86) 7. [将请求方法挂到Vue上](https://github.com/lenve/vhr/wiki/7.%E5%B0%86%E8%AF%B7%E6%B1%82%E6%96%B9%E6%B3%95%E6%8C%82%E5%88%B0Vue%E4%B8%8A) 8. [登录状态的保存](https://github.com/lenve/vhr/wiki/8.%E7%99%BB%E5%BD%95%E7%8A%B6%E6%80%81%E7%9A%84%E4%BF%9D%E5%AD%98) 9. [登录成功后动态加载组件](https://github.com/lenve/vhr/wiki/9.%E7%99%BB%E5%BD%95%E6%88%90%E5%8A%9F%E5%90%8E%E5%8A%A8%E6%80%81%E5%8A%A0%E8%BD%BD%E7%BB%84%E4%BB%B6) 10. [角色资源关系管理](https://github.com/lenve/vhr/wiki/10.%E8%A7%92%E8%89%B2%E8%B5%84%E6%BA%90%E5%85%B3%E7%B3%BB%E7%AE%A1%E7%90%86) 11. [用户角色关系管理]( GitHub 15K star 前后端分离项目视频教程,项目地址:https://github.com/lenve/vhr 注意事项: 1.后端不需要执行sql脚本。 2.前端需要替换镜像源 ![image-20240311142024863](readme.assets/image-20240311142024863.png) # 若依项目升级 ## 仓库 文档:https://doc.ruoyi.vip/ruoyi-vue/ springboot+vue2: https://gitee.com/y_project/RuoYi-Vue vue3: https://github.com/yangzongzhuan/RuoYi-Vue3 uniapp: https://gitee.com/y_project/RuoYi-App ## 升级MybatisPLUS 可以生成带页面的CRUD,提升开发效率 参考:https://blog.csdn.net/weixin_40816738/article/details/132008494 ## 多环境部署 ![image-20230329202828163](readme.assets/image-20230329202828163-169821594936331.png) ``` nohup java -jar xxxx.jar --spring.profiles.active=test --server.port=8080 & #带参数启动 tail -f nohup.out #监控日志 ``` ## 若依雪花算法19位id精度损失问题解决 json转换会导致id精度损失,换String改动太多且影响原有基础功能。后来是重写id算法,降低到15位可以兼容。 ``` package com.jxs.config; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; import com.jxs.params.SysParams; import org.springframework.stereotype.Component; import java.math.BigInteger; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter; import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; /** * 对象映射器:基于jackson将Java对象转为json,或者将json转为Java对象 * 将JSON解析为Java对象的过程称为 [从JSON反序列化Java对象] * 从Java对象生成JSON的过程称为 [序列化Java对象到JSON] */ @Component public class JacksonObjectMapper extends ObjectMapper { public JacksonObjectMapper() { super(); //收到未知属性时不报异常 this.configure(FAIL_ON_UNKNOWN_PROPERTIES, false); //反序列化时,属性不存在的兼容处理 this.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); this.setSerializationInclusion(JsonInclude.Include.NON_NULL); SimpleModule simpleModule = new SimpleModule() .addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(SysParams.DEFAULT_DATE_TIME_FORMAT))) .addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(SysParams.DEFAULT_DATE_FORMAT))) .addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(SysParams.DEFAULT_TIME_FORMAT))) .addSerializer(BigInteger.class, ToStringSerializer.instance) .addSerializer(Long.class, ToStringSerializer.instance) .addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(SysParams.DEFAULT_DATE_TIME_FORMAT))) .addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(SysParams.DEFAULT_DATE_FORMAT))) .addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(SysParams.DEFAULT_TIME_FORMAT))); //注册功能模块 例如,可以添加自定义序列化器和反序列化器 this.registerModule(simpleModule); } } ``` 若依基础上增加模块,不修改(开闭原则) ## 权限实现流程 ## 添加摸一个新模块 git笔记:http://119.23.55.53/mydocs/notes/git.html ## SpringSecurity 教程:https://www.yiibai.com/spring-security/spring-security-hello-world-example.html#article-start ## RuoYi代码生成器 https://doc.ruoyi.vip/ruoyi/document/htsc.html#%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90 ## RBAC https://blog.csdn.net/m0_62006803/article/details/133962328 ![img](README.assets/431130551b4c4932ba40ebd4f3cdaa24.png) ## hutool https://www.hutool.cn/ # Vhr 验证码 http://localhost:8081/verifyCode 部署nginx ![image-20240313100433618](README.assets/image-20240313100433618.png) # 面试 https://javaguide.cn/home.html # 模拟面试 4人/组