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

使用renren-generator逆向生成CRUD代码

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

使用renren-generator逆向生成CRUD代码

使用renren-generator逆向生成CRUD代码
  • 环境以及版本说明
  • 去gitee的开源人人项目中拉去renren-generator项目
    • 1、在gulimall-common中引入renren-generator module
    • 2、修改`generator.properties`中的`moduleName`和`tablePrefix`
    • 3、修改`application.yml`中连接的数据库的名字
    • 4、启动renren-generator项目
    • 5、选中表,直接生成实体类代码
    • 6、将生成的代码中的main文件夹直接复制在对应项目的src/main下

环境以及版本说明
工具版本
JDK1.8.0_301
MySQL5.7.36
IDEA2021.3.3
Maven3.8.5
SpringBoot2.7.1
SpringCloud2021.0.3
MyBatis-Plus3.2.0
Docker20.10.17
去gitee的开源人人项目中拉去renren-generator项目

https://gitee.com/renrenio/renren-generator
git clone https://gitee.com/renrenio/renren-generator

删掉里面的.git文件夹放在你的项目中,需要做出修改的地方有:

1、在gulimall-common中引入renren-generator module

2、修改generator.properties中的moduleName和tablePrefix

3、修改application.yml中连接的数据库的名字

4、启动renren-generator项目

访问目标页面:http://localhost/#main.html

5、选中表,直接生成实体类代码

6、将生成的代码中的main文件夹直接复制在对应项目的src/main下


其他的订单模块,会员模块,仓库模块依次仿照如此。
在Test模块中写CRUD操作,检测是否访问数据库正常

package com.atguigu.gulimall.product;

import com.atguigu.gulimall.product.entity.BrandEntity;
import com.atguigu.gulimall.product.service.BrandService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
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 GulimallProductApplicationTests {

    @Autowired
    BrandService brandService;
    @Test
    void contextLoads() {
//        BrandEntity brandEntity = new BrandEntity();
//        brandEntity.setBrandId(1L);
//        brandEntity.setName("苹果");
//        brandEntity.setDescript("Apple");

//        brandEntity.setName("华为");
//        brandService.save(brandEntity);
//        System.out.println("保存成功");

//        brandService.updateById(brandEntity);

        List list = brandService.list(new QueryWrapper().eq("brand_id", 1L));
        list.forEach((item)->{
            System.out.println(item);
        });
    }

}


【坑1】
在最后一个gulimall-ware模块中报错:无法加载主类

错误: 找不到或无法加载主类 com.atguigu.gulimall.ware.GulimallWareApplication

解决方法:maven ===> clean ===> compile

【坑2】
报错:找不到factorybean,注入失败,是lombok=1.18.4的版本太低,不匹配。建议改为如下版本

1.18.14

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1020720.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

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

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