Java资源分享网 - 专业的Java学习网站 学Java,上Java资源分享网
MybatisPlus使用实战,MybatisPlus简介和使用示例 PDF 下载
匿名网友发布于:2024-03-05 10:15:51
(侵权举报)
(假如点击没反应,多刷新两次就OK!)

MybatisPlus使用实战,MybatisPlus简介和使用示例 PDF 下载  图1

 

 

资料内容:

 

1.2 添加依赖

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId>

<scope>test</scope>

</dependency>

<dependency>

<groupId>org.projectlombok</groupId>

<artifactId>lombok</artifactId>

<optional>true</optional>

</dependency>

<dependency>

<groupId>com.baomidou</groupId>

<artifactId>mybatis-plus-boot-starter</artifactId>

<version>3.3.1.tmp</version>

</dependency>

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

<scope>runtime</scope>

<version>5.1.46</version>

</dependency>

</dependencies>

 

1.3 配置文件

 

2.3.1 在 application.yml 配置文件中添加 Mysql 数据库的

相关配置:

server:

port: 4321

spring:

profiles:

active: /

datasource:

url:

jdbc:mysql://10.20.7.143:3306/test_mysql?useUnicode=true&useSSL=false&characterEncoding=

UTF-8&serverTimezone=Asia/Shanghai

username: root

password: 123456

driver-class-name: com.mysql.jdbc.Driver

mybatis-plus:

configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

mapper-locations: classpath*:mapper/*.xml

 

2.3.2 在 Spring Boot 启动类中添加 @MapperScan 注解,

扫描 Mapper 文件夹:

@SpringBootApplication@MapperScan("com.baomidou.mybatisplus.samples.quickstart.mapper")

public class Application {

public static void main(String[] args) {

SpringApplication.run(QuickStartApplication.class, args);

}

}

 

1.4 编码

 

2.4.1 编写实体类 User.java(此处使用了 Lombok 简化代码)

@Data

public class User {

private Long id;

private String name;

private Integer age;

private String email;

}