# mybati-Plus **Repository Path**: mr_sen/mybati-Plus ## Basic Information - **Project Name**: mybati-Plus - **Description**: mybatis_plus学习记录 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-06-22 - **Last Updated**: 2021-06-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 使用步骤 >步骤一:添加依赖 ```xml com.baomidou mybatis-plus-boot-starter 3.4.3.1 org.springframework.boot spring-boot-starter mysql mysql-connector-java runtime org.projectlombok lombok true org.springframework.boot spring-boot-starter-test test ``` >步骤二:配置数据源 ```properties spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver ##踩得的小坑,是pring.datasource.username而不是 ##pring.datasource.name,这样会会是你window的登陆name spring.datasource.username=root spring.datasource.password=root spring.datasource.url=jdbc:mysql://192.168.163.163:3306/mybatis2?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai ``` >步骤三:设置包扫描 ```java @Configuration @MapperScan("com.lovexk.dao") //扫描包 public class MybatisPlusConfig { //分页 @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); return interceptor; } // 自己插入主键时,生成主键 ;可以自己实现IdentifierGenerator接口 @Bean public IdentifierGenerator identifierGenerator() throws UnknownHostException { InetAddress localHost = InetAddress.getLocalHost(); return new DefaultIdentifierGenerator(localHost); } } ```