spring boot,mybatis,angularjs 整合实例

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数据库dbtest
  • 2.导入spring-boot-project\spring-boot-web\src\main\resources目录下的dbtest.sql
  • 3.设置配置文件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
api文档测试

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 {
    //这里验证用户是否登录
}

完整的项目代码

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值