Dept 1. 添加依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.2</version>
</dependency>
Dept2: 配置环境
package com.db.common.config;
/**
* 注解配置应用说明:
* @ComponentScan 修饰配置类,用于定义要对哪些保重类型进行扫描,
* 属性value指定具体要扫描的包,属性excludeFilters表示对扫描包中的哪些类不进行加载
*
* 其中Controller.class,ControllerAdvice.class
* 为web请求层spring中的常用注解
*/
@ComponentScan(//@Component,@Controller,@Service,@Configuration...
value="com.db",
//要排除加载的类(例如使用controller注解修饰的类不进行加载)
excludeFilters={
@Filter(type=FilterType.ANNOTATION,//约束classes属性中的内容
classes={Controller.class,
ControllerAdvice.class})})//<context:component-scan base-package="com.jt"/>
public class AppRootConfig {//取代spring-configs.xml
}
package com.db.common.config;
@Configuration
@MapperScan(basePackages="com.db.**.dao")
/**等上
* @Bean
public MapperScannerConfigurer getScanner(){
MapperScannerConfigurer scanner=new MapperScannerConfigurer();
scanner.setBasePackage("com.db.**.dao");
return scanner;
} */
public class AppMyBatisConfig {
/**配置PageInterceptor插件*/
@Bean
public PageInterceptor getPageInterceptor(){
PageInterceptor pageIntercptor=new PageInterceptor();
Properties properties=new Properties();
properties.setProperty("value", "true");
pageIntercptor.setProperties(properties);
return pageIntercptor;
}
@Bean("sqlSession