RuoYi_Vue前后分离-_-服务端导入Mybatis-plus

1.springApplication 工程

org.projectlombok

lombok

1.16.10

com.baomidou

mybatis-plus-boot-starter

3.3.0

com.baomidou

mybatis-plus-extension

3.3.0

 

2.在Application启动类同目录下创建API文件

RuoYi_Vue前后分离-_-服务端导入Mybatis-plus_第1张图片

 

3.0SQL

CREATE TABLE `demo` (

`id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,

`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,

 

PRIMARY KEY (`id`) USING BTREE

) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

 

INSERT INTO `demo` VALUES ('1', 'v_v');

3.domain--现有的mybatis声明domain:因为SqlSessionFactory需要读现有的mybatis和我们要增加的mybatis-plus

/**

* @ClassName Demo

* @Description TODO

* @Author V_V

* @Date 2020/5/18 19:24

* @Version 1.0

**/

@Data

@TableName("demo")

public class Demo{

 

@TableId(value = "id", type = IdType.UUID)

private String id;

@TableField("name")

private String name;

}

4.0Mapper同domain

package com.ruoyi.api.mapper;

 

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.ruoyi.api.domain.Demo;

 

 

/**

* @ClassName DemoMapper

* @Description TODO

* @Author V_V

* @Date 2020/5/18 19:30

* @Version 1.0

**/

public interface DemoMapper extends BaseMapper {

}

5.0service

 

import com.baomidou.mybatisplus.extension.service.IService;

import com.ruoyi.api.domain.Demo;

 

 

/**

* @ClassName DemoService

* @Description TODO

* @Author V_V

* @Date 2020/5/18 19:32

* @Version 1.0

**/

public interface DemoService extends IService {

}

5.1service-imp

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

 

import com.ruoyi.api.domain.Demo;

import com.ruoyi.api.mapper.DemoMapper;

import com.ruoyi.api.service.DemoService;

import org.springframework.stereotype.Service;

 

/**

* @ClassName DemoServiceImpl

* @Description TODO

* @Author V_V

* @Date 2020/5/18 19:32

* @Version 1.0

**/

@Service

public class DemoServiceImpl extends ServiceImpl implements DemoService {

}

6.jar包冲突解决

IDEA 安装maven Helper插件

当Maven Helper 插件安装成功后,打开项目中的pom文件,下面就会多出一个试图

RuoYi_Vue前后分离-_-服务端导入Mybatis-plus_第2张图片

切换到此试图即可进行相应操作:

  1. Conflicts(查看冲突)
  2. All Dependencies as List(列表形式查看所有依赖)
  3. All Dependencies as Tree(树形式查看所有依赖)

当前界面上还提供搜索功能 方便使用

RuoYi_Vue前后分离-_-服务端导入Mybatis-plus_第3张图片

冲突解决

RuoYi_Vue前后分离-_-服务端导入Mybatis-plus_第4张图片

 

7.找到MyBatisConfig的配置

把mybatis SqlSessionFactory修改为mybatis-plus的MybatisSqlSessionFactoryBean

 

8.配置好权限请求成功

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(RuoYi,mybatis,mysql,java)