1、配置
application.yml
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 设置MyBatis-Plus的全局配置
global-config:
db-config:
# 设置实体类所对应的表的统一前缀
table-prefix: t_
# 设置统一的主键生成策略
id-type: auto
# 配置类型别名所对应的包
type-aliases-package: com.rjs.mybatisplus.pojo
# 扫描通用枚举的包
type-enums-package: com.rjs.mybatisplus.enums
2、测试
@SpringBootTest // Spring 测试
public class MyBatisPlusTest {
@Autowired // 自动装配Mapper
private UserMapper userMapper;
@Test
public void testSelectList(){
//通过条件构造器查询一个list集合,若没有条件,则可以设置null为参数
List<User> list = userMapper.selectList(null);
list.forEach(System.out::println);
}
}
显示SQL语句
版权声明:本文为weixin_44593925原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。