springboot整合mybatis,swagger ui
来源:互联网 发布:微博的个性域名怎么改 编辑:程序博客网 时间:2024/06/05 07:05
项目整体结构
pom.xml文件
4.0.0 hongyi springboot-mybatis0.0.1-SNAPSHOT war UTF-8 1.7 1.3.0 org.springframework.boot spring-boot-starter-parent1.5.8.RELEASE org.springframework.boot spring-boot-starter-weborg.springframework.boot spring-boot-starter-tomcatorg.mybatis.spring.boot mybatis-spring-boot-starter${mybatis-spring-boot.version} com.github.pagehelper pagehelper5.1.1 mysql mysql-connector-javaio.springfox springfox-swagger22.6.1 io.springfox springfox-swagger-ui2.6.1 javax.servlet javax.servlet-apiprovided javax.servlet jstlorg.apache.tomcat.embed tomcat-embed-jasperorg.slf4j slf4j-log4j12provided org.springframework.boot spring-boot-maven-pluginsrc/main/webapp META-INF/resources **/** src/main/resources **/** false
创建application.properties,位置是src/java/resources下
##数据库配置信息spring.datasource.url=jdbc:mysql://localhost:3306/easyui?userUnicode=true&characterEncoding=UTF8&useSSL=falsespring.datasource.username=rootspring.datasource.password=donghuspring.datasource.driver-class-name=com.mysql.jdbc.Driver#设置包的别名mybatis.typeAliasesPackage=com.hy31.pojo#设置mapper.xml文件的位置mybatis.mapperLocations=classpath:mapper/*.xml#设置springmvc的前缀spring.mvc.view.prefix=/WEB-INF/jsp/#后缀spring.mvc.view.suffix=.jsp
mybatis分页插件配置
/** * 此类属于配置类,代替xml配置 */@SpringBootConfigurationpublic class MybatisConfig {/** * 分页插件配置 * @return */@Beanpublic PageInterceptor getPageInterceptor() {PageInterceptor pageInterceptor = new PageInterceptor();Properties properties = new Properties();// // properties.setProperty("offsetAsPageNum", "true");// 设置为true时,使用RowBounds分页会进行count查询 会去查询出总数 properties.setProperty("rowBoundsWithCount", "true");// 分页合理化properties.setProperty("reasonable", "true");pageInterceptor.setProperties(properties);return pageInterceptor;}// 配置mybatis的分页插件pageHelper 4.X版本 配置/* * @Bean public PageHelper pageHelper(){ PageHelper pageHelper = new * PageHelper(); Properties properties = new Properties(); * properties.setProperty("offsetAsPageNum","true"); * properties.setProperty("rowBoundsWithCount","true"); * properties.setProperty("reasonable","true"); * properties.setProperty("dialect","mysql"); //配置mysql数据库的方言 * pageHelper.setProperties(properties); return pageHelper; } */}
程序主入口
//MyBatis 扫描mapper接口@MapperScan("com.hy31.mapper")@SpringBootApplicationpublic class SBApplication extends SpringBootServletInitializer {/** * 打成war发布,重写此方法 */@Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(SBApplication.class); }public static void main(String[] args) throws Exception { SpringApplication.run(SBApplication.class, args); }}
swagger-ui使用这里暂时不详细写,只截图:
阅读全文
0 0
- springboot整合mybatis,swagger ui
- springboot+mybatis+resteasy+swagger整合
- springboot整合swagger UI 、spring-data-JPA
- springboot整合swagger
- springboot整合swagger
- SpringBoot整合Swagger
- SpringBoot整合swagger
- SpringBoot整合Swagger
- springboot 集成 Swagger ui
- Swagger与SpringBoot的整合
- Swagger与SpringBoot的整合
- Springboot整合Swagger学习笔记
- springmvc或者springboot整合swagger
- 采用shardbatis在springBoot中实现表的水平拆分,整合swagger,mybatis,shardbatis,pagehelper
- 采用shardbatis在springBoot中实现表的水平拆分,整合swagger,mybatis,shardbatis,pagehelper
- swagger 与 springboot 的整合实战
- SpringBoot开发案例之整合Swagger篇
- SpringBoot整合Swagger自动生成API文档
- python工程师(web开发和爬虫方向)-面试经历
- java网络编程小谈
- pom配置文件---ssm(学习笔记)
- Pycharm中本地包导入问题Unresolved reference
- 洛谷P2820 局域网
- springboot整合mybatis,swagger ui
- 10.19周四
- 最新微信退款结果通知解密(php版)
- 开源项目:购物软件的开发
- shiro学习笔记
- Linux编程预习-函数
- Leetcode 695. Max Area of Island
- 【网络编程】TCP状态转换图(重点)
- 树状数组