本例子需要使用mysql,运行之前请确保已经安装mysql,如果未安装请自行下载,或者再百度网盘中下载,下载地址:https://pan.baidu.com/s/1pLDKOm3#list/path=%2F
本例子整合了springboot、mysql、easyUI,并提供了一个简单的easyUI datagrid列表样例
运行本例子前请先执行create.sql创建数据库(下载包里面有)
1、源码截图
2、具体设计到哪些代码
① MyBatisConfig类配置了mybatis的事务、sqlSessionFactory、mapper、model;MyBatisMapperScannerConfig配置了mybatis的model,MybatisCustomVFS是自定义的VFS,springboot项目打包之后class文件全都在BOOT-INF/classes/目录下,所以model会因为路径问题扫描不到,在VFS中处理该问题,WebConfig中配置了CharacterEncodingFilter,防止出现乱码
① plugins目录下的jQuery和easyUI插件未做任何改变
3、配置文件说明
spring:application:name: springtestdatasource:type: com.alibaba.druid.pool.DruidDataSource #使用druid连接池url: jdbc:mysql://localhost:3306/role?characterEncoding=UTF-8username: rootpassword: rootdriver-class-name: com.mysql.jdbc.Drivermax-idle: 5max-wait: 60000maxWait: 60000min-idle: 5minIdle: 5maxActive: 20initial-size: 5initialSize: 5validation-query: SELECT 1timeBetweenEvictionRunsMillis: 60000minEvictableIdleTimeMillis: 300000validationQuery: SELECT 1testWhileIdle: truetestOnBorrow: falsetestOnReturn: falsepoolPreparedStatements: truemaxPoolPreparedStatementPerConnectionSize: 20filters: stat,wall,log4jconnectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000useGlobalDataSourceStat: truejdbc-interceptors: ConnectionState;SlowQueryReport(threshold=50)thymeleaf: cache: falsecache-period: 0
template: cache: falseserver:port: 8080tomcat:uri-encoding: UTF-8
1、直接执行com.springtest.Application即可运行(含有main方法,直接运行即可),访问地址是http://localhost:8080/
2、运行时的截图
例子中只是简单的对springboot 、mybatis 、 easyUI做了整合,mybatis未加入分页插件,如果需要请自行加入,和标准的Java项目使用方式无任何区别,easyUI和在标准的Java项目中使用方式也没区别
mybatis文档:http://www.mybatis.org/mybatis-3/zh/index.html
分页插件:https://github.com/pagehelper/Mybatis-PageHelper
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态