mybatis-plus的驼峰映射配置信息优先级高于mybatis的配置
时间: 2023-06-28 17:04:15 浏览: 49
是的,MyBatis-Plus的驼峰映射配置信息优先级高于MyBatis的配置。这是因为MyBatis-Plus的驼峰映射配置是通过继承MyBatis的Configuration类来实现的,因此MyBatis-Plus的配置会覆盖MyBatis的配置。如果你想要使用MyBatis的配置,可以在MyBatis-Plus的配置中将驼峰映射禁用,例如:
```java
mybatis-plus:
configuration:
map-underscore-to-camel-case: false
```
这样就可以使用MyBatis的下划线映射配置了。
相关问题
mybatis-plus开启驼峰映射
Mybatis-plus开启驼峰映射可以在配置文件中配置,如下:
```
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
```
还可以在实体类上加注解@TableName(value = "表名", resultMap = "BaseResultMap") 来开启驼峰映射
mybatis-plus分页插件配置springboot
好的,下面是 Mybatis-Plus 分页插件配置 Spring Boot 的步骤:
1. 首先,需要在 pom.xml 中添加 Mybatis-Plus 的依赖:
```
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.x.x</version>
</dependency>
```
2. 然后,在 Spring Boot 的配置文件中,添加 Mybatis-Plus 的配置:
```
# Mybatis-Plus 配置
mybatis-plus:
# mapper 映射文件位置
mapper-locations: classpath*:mapper/*.xml
# 自动填充配置
global-config:
db-config:
# 数据库字段自动填充
field-strategy: not_empty
# 数据库插入操作,自动填充字段
insert-strategy: not_null
# 数据库更新操作,自动填充字段
update-strategy: not_null
```
3. 接下来,在代码中使用 Mybatis-Plus 提供的 Page 类来进行分页查询:
```
// 创建分页对象
Page<User> page = new Page<>(pageNum, pageSize);
// 查询数据
List<User> userList = userMapper.selectPage(page, null);
// 获取分页信息
PageInfo<User> pageInfo = new PageInfo<>(userList);
```
其中,pageNum 表示当前页码,pageSize 表示每页显示的数据条数,userMapper 是 Mybatis-Plus 自动生成的 Mapper 类。
以上就是 Mybatis-Plus 分页插件配置 Spring Boot 的简单步骤,希望能对你有所帮助。