springboot整合mybatis小练习 对员工表的增删改查【连表分页】

springboot整合mybatis小练习 对员工表的增删改查【连表分页】,第1张

springboot整合mybatis小练习 对员工表的增删改查【连表分页】

对员工表的增删改查【连表分页】
测试接口

项目结构

导入依赖

 
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            2.2.0
        

        
            mysql
            mysql-connector-java
            runtime
        
        
            org.projectlombok
            lombok
            true
        
        
            com.alibaba
            druid-spring-boot-starter
            1.2.1
        
        
            com.github.pagehelper
            pagehelper-spring-boot-starter
            1.2.13
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    

application.yml

#配置端口号
server:
  port: 8080
#  配置druid的信息
spring:
  datasource:
    druid:
      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://localhost:3306/emp?serverTimezone=Asia/Shanghai
      username: root
      password: root
      max-active: 20
      initial-size: 5
      min-idle: 5
      max-wait: 3000
  main:
    allow-circular-references: true
# 配置mybatis映射文件所在的路径
mybatis:
  mapper-locations: classpath:mapper/*.xml
# mybatis输入sql语句
logging:
  level:
    com.ccr.dao: debug
#pageHelper
pagehelper:
  reasonable: true #分页合理化

EmpMapper.xml




    
        
        
        
        
        
        
            
            
        
    
    
    
     SELECT e.empId, e.empName,e.gender,e.email,e.d_Id  from  tbl_emp e
        INNER JOIN tbl_dept t
        on t.deptId=e.d_Id
     where e.empId=#{empId}