spring boot,mybatis,angularjs 整合实例

xiaoxiao2021-02-28  115

spring-boot,mybatis,angularjs整合实例

项目简介

采用spring-boot搭建项目,IDE采用Eclipse,数据库支持Mysql以及H2,集成了Mybatis、AngularJS、百度编辑器、文件上传、Redis、Solr、验证码以及微信等功能,前后台数据传输采用JSON方式,同时实现了登录拦截器以及跨域访问的配置。

项目结构:

spring-boot-project

spring-boot-common: 常用工具类 spring-boot-mapperpojo:从数据库导出的model以及mapper spring-boot-pagepojo:页面model spring-boot-service:服务层 spring-boot-web:页面,项目打包位置以及配置文件

使用方法

1.创建一个Mysql数据库dbtest2.导入spring-boot-project\spring-boot-web\src\main\resources目录下的dbtest.sql3.设置配置文件application.yml,修改static-locations中的webapp路径指向本地路径,修改datasource中的数据库配置参数4.运行spring-boot-web项目,选中Application.java,run as->java application

运行效果

1.用户管理:http://localhost:8002/admin/user/user.jsp

2.验证码:http://localhost:8002/

3.文件上传:http://localhost:8002/file.html

4.百度编辑器:http://localhost:8002/jslib/plugins/ueditor/index.html

5.api文档:http://localhost:8002/swagger-ui.html

Mapper代码生成

在spring-boot-mapperpojo项目中,配置好src/main/resources/generator/generatorConfig.xml配置文件中的包名和路径,为了避免被重复覆盖,在mapper的java和xml文件导出路径中加了mappertemp目录,此目录仅作导出存储,需要手工复制一份到mapper路径。导出时采用mvn mybatis-generator:generate,如果是用maven build…菜单只要输入mybatis-generator:generate

登录拦截器

在spring-boot-web项目中的com.kpttech.web包中的AdminInterceptor类。

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception { //这里验证用户是否登录 }

完整的项目代码

转载请注明原文地址: https://www.6miu.com/read-47682.html

最新回复(0)