- 技术
- 新建工程
- 修改Pom配置文件
- 实体类LomBok简单使用
- application.yml文件配置
- Dao层
- 测试类
- 数据库
- 可能遇到的问题
- CLIENT_PLUGIN_AUTH is required
MyBatisPlus使用时候,要求你的数据库的名字与表名一致,不然找不到
技术
- 实体类开发 LomBok - Dao开发 MyBatisPlus - Service开发 - Controller开发 Restful - 页面开发 Vue+ElementUI - 项目异常处理 - 分页展示新建工程
实体类LomBok简单使用4.0.0 org.springframework.boot spring-boot-starter-parent 2.6.1 com.abc learn 0.0.1-SNAPSHOT 1.8 com.alibaba druid-spring-boot-starter 1.2.8 com.baomidou mybatis-plus-boot-starter 3.4.3.4 org.springframework.boot spring-boot-starter-web mysql mysql-connector-java runtime org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-maven-plugin
https://blog.csdn.net/qq_44627608/article/details/121975611
application.yml文件配置# 服务器端口号
server:
port: 80
# SQL驱动
spring:
datasource:
druid:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/learn_sql
username: root
password: 123456
# MyBatisPlus配置数据库表名的前后缀
mybatis-plus:
global-config:
db-config:
table-prefix: learn_
Dao层
@Mapper public interface StudentDao extends baseMapper测试类{ }
package com.abc;
import com.abc.dao.StudentDao;
import com.abc.entity.Student;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
class LearnApplicationTests {
@Autowired
private StudentDao dao;
@Test
void contextLoads() {
List lists=dao.selectList(null);
for (Student entity : lists) {
System.out.println(entity.toString());
}
}
}
数据库
可能遇到的问题
CLIENT_PLUGIN_AUTH is required
更换pom配置文件里的SQL驱动版本
mysql
mysql-connector-java
runtime
加入下面这一行,多试几个就ok了。
5.1.49



