赞
踩
这是一款基于SpringBoot+Vue的前后端分离的项目,麻雀虽小,五脏俱全,值得拥有!
全部源码放到文章最后
页面展示:
后端
SpringBoot
Hutool工具类库(*超好用)
Redis缓存 (缓解多次刷新数据库压力)
Lombok(减少写get、set等方法)
Mysql5.7+
Mybatis
Mybatis-Plus
前端
Vue2
Vue-Router
VueX
ElementUI
Apache ECharts (可视化图标插件)
Axios
高德地图Api
Mysql5.7+ 、Nvaicat(MySQL可视化工具)
字符集
utf8mb4
排序规则
utf8mb4_unicode_ci
目录结构
改成自己配置即可
server: ip: localhost port: 9090 spring: datasource: driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/boot?serverTimezone=GMT%2b8&useUnicode=true&characterEncoding=utf-8&useSSL=false username: root password: redis: host: localhost port: 6379 password: servlet: multipart: max-file-size: 100MB max-request-size: 100MB mybatis: mapper-locations: classpath:mapper/*.xml #扫描所有mybatis的xml文件 # configuration: # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl mybatis-plus: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl files: upload: path: /usr/xmp/files/
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.2.1</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> <version>5.1.47</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <!-- mybatis-plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.1</version> </dependency> <!-- 代码生成器 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> <version>3.5.1</version> </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> <version>1.7</version> </dependency> <!--swagger--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency> <!-- hutool --> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.7.20</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>4.1.2</version> </dependency> <!-- JWT --> <dependency> <groupId>com.auth0</groupId> <artifactId>java-jwt</artifactId> <version>3.10.3</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies>
package sqgxy.xmp.springboot.config.interceptor; import cn.hutool.core.util.StrUtil; import com.auth0.jwt.JWT; import com.auth0.jwt.JWTVerifier; import com.auth0.jwt.algorithms.Algorithm; import com.auth0.jwt.exceptions.JWTDecodeException; import com.auth0.jwt.exceptions.JWTVerificationException; import sqgxy.xmp.springboot.common.Constants; import sqgxy.xmp.springboot.config.AuthAccess; import sqgxy.xmp.springboot.entity.User; import sqgxy.xmp.springboot.exception.ServiceException; import sqgxy.xmp.springboot.service.IUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerInterceptor; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * @author xmp * @date 2022/5/9 * @description JwtInterceptor * jwt拦截器 */ public class JwtInterceptor implements HandlerInterceptor { @Autowired private IUserService userService; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { String token = request.getHeader("token"); // 如果不是映射到方法直接通过 if(!(handler instanceof HandlerMethod)){ return true; } else { HandlerMethod h = (HandlerMethod) handler; AuthAccess authAccess = h.getMethodAnnotation(AuthAccess.class); if (authAccess != null) { return true; } } // 执行认证 if (StrUtil.isBlank(token)) { throw new ServiceException(Constants.CODE_401, "无token,请重新登录"); } // 获取 t
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。