mybatis升级为mybatis-plus需要修改3个地方
一.去掉mybatis依赖,引入mybatis-plus依赖
1.去掉mybatis依赖
<!--去掉mybatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.5</version>
</dependency>
<!--去掉mybatis-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.2.0</version>
</dependency>
2.引入mybatis-plus依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.3</version>
</dependency>
注意还要引入,因为mybayis-plus会结合lombok注解使用
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.18</version>
</dependency>
二.修改配置文件
将
mybatis.mapper-locations=classpath:/mybatis/*Mapper.xml
mybatis.type-aliases-package=lzgene.newscreening.model
mybatis.configuration.map-underscore-to-camel-case=true
mybatis.configuration.default-fetch-size=100
mybatis.configuration.default-statement-timeout=30
改为
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
mybatis-plus.configuration.jdbc-type-for-null=null
mybatis-plus.configuration.lazy-loading-enabled=true
mybatis-plus.configuration.aggressive-lazy-loading=false
mybatis-plus.mapper-locations=classpath:mapper/**/*.xml
mybatis-plus.global-config.banner=false
mybatis-plus.global-config.db-config.select-strategy:not_empty
三.修改启动类Application,添加扫描的包
将@MapperScan("com.xinshai.dao")改为@MapperScan({"com.xinshai.dao","com.xinshai.test.mapper"})
其中com.xinshai.dao是没升级前使用的 ,com.xinshai.test.mapper是升级使用mybatis-plus新增的接口包路径