Mybatis-puls配置|Mybatis-puls配置 多表查询
mybatis-puls
mybatis-plus依赖
com.baomidou
mybatis-plus-boot-starter
3.4.1
application.yml配置
server:
port: 8003
spring:
datasource:
url: jdbc:mysql:/IP地址//数据库?serverTimezone=GMT%2B8&CharacterEncoding=utf8
username: 账号
password: 密码
mybatis-plus:
# 扫描xml文件
mapper-locations: classpath:/mapper/*.xml
configuration:
# 控制台打印执行SQL语句
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
启动类扫描mapper
@SpringBootApplication
//扫描
@MapperScan("com.jsd.mapper")
public class Springcloud03Application {public static void main(String[] args) {
SpringApplication.run(Springcloud03Application.class, args);
}}
pojo
User
@Data
//数据库表名
@TableName("user")
public class User implements Serializable {
private Integer Id;
private String Name;
private Integer Age;
private String Email;
//对象
private Message message;
//嵌套集合
private List messageList;
}
【Mybatis-puls配置|Mybatis-puls配置 多表查询】Message
@Data
@TableName("message")
public class Message implements Serializable {
private Integer Id;
private String Message;
}
UserMapper接口
//继承BaseMapper<>
public interface UserMapper extends BaseMapper{List selectAll();
List selectLists();
}
UserMapper.xml文件
select
a.id,a.name,a.age,a.email,b.message
from user a join message b
on a.id=b.idselect
a.id,a.name,a.age,a.email,b.message
from user a join message b
on a.id=b.id
推荐阅读
- java|Docker配置文件位置
- java|SpringBoot集成Dubbo详细配置
- idea|IDEA 配置可视化数据库视图
- GitBook项目搭建、插件配置、打包(插入ppt、视频、pdf)
- 关于PyTorch环境配置及安装教程(Windows10)
- 面试|MySQL 免安装版的下载与配置教程
- java|Mysql环境变量配置
- ssm中使用kindedit|springboot项目中需要配置文件上传解析器吗_Spring Boot2 系列教程(一)纯 Java 搭建 SSM 项目...
- ecarts|echarts(三)常用图表(折线图、饼图、散点图、K线图极其常用配置项)
- SSM框架学习|SSM框架学习——SpringBoot之基础配置