Python知識分享網(wǎng) - 專業(yè)的Python學(xué)習(xí)網(wǎng)站 學(xué)Python,上Python222
MybatisPlus使用實戰(zhàn),MybatisPlus簡介和使用示例 PDF 下載
發(fā)布于:2024-01-27 15:30:38
(假如點擊沒反應(yīng),多刷新兩次就OK!)

MybatisPlus使用實戰(zhàn),MybatisPlus簡介和使用示例 PDF 下載  圖1

 

 

 

資料內(nèi)容:

 

 

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 數(shù)據(jù)庫的
相關(guān)配置:
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;
}