更新依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>${mybaitsplus.version}</version>
</dependency>
替换相关导入包
替换方法
原路径 | 替换路径 |
---|---|
com.baomidou.mybatisplus.activerecord.Model | com.baomidou.mybatisplus.extension.activerecord.Model |
com.baomidou.mybatisplus.annotations.TableId | com.baomidou.mybatisplus.annotation.TableId |
com.baomidou.mybatisplus.enums.IdType | com.baomidou.mybatisplus.annotation.IdType |
com.baomidou.mybatisplus.service.impl.ServiceImpl | com.baomidou.mybatisplus.extension.service.impl.ServiceImpl |
com.baomidou.mybatisplus.mapper.BaseMapper | com.baomidou.mybatisplus.core.mapper.BaseMapper |
com.baomidou.mybatisplus.plugins.Page | com.baomidou.mybatisplus.extension.plugins.pagination.Page |
com.baomidou.mybatisplus.service.IService | com.baomidou.mybatisplus.extension.service.IService |
com.baomidou.mybatisplus.mapper.EntityWrapper | com.baomidou.mybatisplus.core.conditions.query.QueryWrapper |
com.baomidou.mybatisplus.toolkit.StringUtils | com.baomidou.mybatisplus.core.toolkit.StringUtils |
com.baomidou.mybatisplus.annotations.TableField | com.baomidou.mybatisplus.annotation.TableField |
com.baomidou.mybatisplus.annotations.TableName | com.baomidou.mybatisplus.annotation.TableName |
com.baomidou.mybatisplus.exceptions.MybatisPlusException | com.baomidou.mybatisplus.exceptions.MybatisPlusException |
Mapper
去除了insertAllColumn(T entity),updateAllColumn(T entity)方法
新增update(T entity, Wrapper updateWrapper)方法
Service
insert和insertXXX方法改成了save和saveXXX方法
selectXXX方法改成了getXXX方法
deleteXXX改成了removeXXX方法
spring工程修改spring-mybaits配置文件
<!-- Spring整合Mybatis -->
<bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!-- 自动扫描Mapping.xml文件 -->
<property name="mapperLocations" value="classpath*:/sqlMapperXml/*.xml"></property>
<property name="configLocation" value="classpath:xml/mybatis-config.xml"></property>
<property name="typeAliasesPackage" value="com.project.ysb2.model"/>
<property name="plugins">
<array>
<!-- 分页插件配置 -->
<bean id="mybatisPlusInterceptor" class="com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor">
<property name="interceptors">
<list>
<ref bean="paginationInnerInterceptor"/>
</list>
</property>
</bean>
</array>
</property>
</bean>
<bean id="paginationInnerInterceptor"
class="com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor">
<!-- 指定数据库为MySQL -->
<constructor-arg name="dbType" value="MYSQL"/>
</bean>
spring工程修改mybaits-config配置文件
增加以下配置项
<setting name="mapUnderscoreToCamelCase" value="false"/>
评论区