springboot整合mybatis,swagger ui
2017-10-19 22:57
435 查看
项目整体结构
pom.xml文件
创建application.properties,位置是src/java/resources下
mybatis分页插件配置
程序主入口
启动:
swagger-ui使用这里暂时不详细写,只截图:
pom.xml文件
4.0.0hongyispringboot-mybatis0.0.1-SNAPSHOTwarUTF-81.71.3.0org.springframework.bootspring-boot-starter-parent1.5.8.RELEASEorg.springframework.bootspring-boot-starter-weborg.springframework.bootspring-boot-starter-tomcatorg.mybatis.spring.bootmybatis-spring-boot-starter${mybatis-spring-boot.version}com.github.pagehelperpagehelper5.1.1mysqlmysql-connector-javaio.springfoxspringfox-swagger22.6.1io.springfoxspringfox-swagger-ui2.6.1javax.servletjavax.servlet-apiprovidedjavax.servletjstlorg.apache.tomcat.embedtomcat-embed-jasperorg.slf4jslf4j-log4j12providedorg.springframework.bootspring-boot-maven-pluginsrc/main/webappMETA-INF/resources**/**src/main/resources**/**false
创建application.properties,位置是src/java/resources下
##数据库配置信息 spring.datasource.url=jdbc:mysql://localhost:3306/easyui?userUnicode=true&characterEncoding=UTF8&useSSL=false spring.datasource.username=root spring.datasource.password=donghu spring.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配置 */ @SpringBootConfiguration public class MybatisConfig { /** * 分页插件配置 * @return */ @Bean public 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") @SpringBootApplication public 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使用这里暂时不详细写,只截图:
相关文章推荐
- 记录在eclipse用maven整合springboot+mybatis
- springboot整合mybatis
- springboot整合Mybatis(一)——入门
- Spring boot Mybatis 整合(注解版)
- Eclipse+maven+springboot+mybatis整合
- SpringBoot+Redis+Mybatis+AngularJS整合开发
- Spring boot环境搭建(三)- 整合Mybatis
- Spring Boot + MyBatis 整合 案例
- SpringBoot整合MyBatis
- spring-boot整合mybatis(使用Fiddler抓包工具进行测试)
- 详解SpringBoot 快速整合Mybatis(去XML化+注解进阶)
- SpringBoot04 SpringBoot 和 MyBatis 整合
- springBoot整合mybatis
- springboot与mybatis整合dao层不能注入的问题
- SpringBoot整合MyBatis逆向工程及 MyBatis通用Mapper实例详解
- Spring boot整合mybatis
- SpringBoot+mybatis+gradle的多模块项目整合
- SpringBoot(五):SpringBoot整合MyBatis
- Springboot 整合 Mybatis 的完整 Web 案例
- SpringBoot整合MyBatis