栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot2 黑马B站版 -06 SpringBoot的SSMP整合案例

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot2 黑马B站版 -06 SpringBoot的SSMP整合案例

文章目录
  • 技术
  • 新建工程
  • 修改Pom配置文件
  • 实体类LomBok简单使用
  • application.yml文件配置
  • Dao层
  • 测试类
  • 数据库
  • 可能遇到的问题
    • CLIENT_PLUGIN_AUTH is required

MyBatisPlus使用时候,要求你的数据库的名字与表名一致,不然找不到


技术
- 实体类开发 LomBok
- Dao开发 MyBatisPlus
- Service开发
- Controller开发   Restful
- 页面开发  Vue+ElementUI
- 项目异常处理
- 分页展示
新建工程


修改Pom配置文件


    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
            
        
    


实体类LomBok简单使用

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
        
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/667647.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号