1. 程式人生 > 實用技巧 >mybatis專案升級到mybatis-plus專案

mybatis專案升級到mybatis-plus專案

1.註釋mybatis-starter

新增 mybatis-plus

```  <dependency>
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.3.2</version>
</dependency>
```

2.配置檔案mybatis修改為mybatis-puls

mybatis-puls:
  mapper-locations:
    - classpath*:com/**/mapper/*.xml
    - classpath*:mapper/*.xml

3.新增MybatisPlusConfig配置檔案

@Configuration
@MapperScan(basePackages = {"com.xxxx.xxxx.mapper"})
@EnableTransactionManagement
public class MybatisPlusConfig {
    /**
     * 效能分析攔截器,不建議生產使用
     */
//    @Bean
//    public PerformanceInterceptor performanceInterceptor(){
//        return new PerformanceInterceptor();
//    }

    /**
     * 分頁外掛
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    /**
     * pagehelper的分頁外掛
     */
    @Bean
    public PageInterceptor pageInterceptor() {
        return new PageInterceptor();
    }

}