尚硅谷 2020 谷粒商城项目 笔记(二) 初始化微服务项目 数据库 逆向工程 测试

2 篇文章 0 订阅
2 篇文章 0 订阅

目录

1、初始化微服务

1.1、创建Maven工程项目 

1.1.1、创建新的项目

1.1.2、选择 Maven 项目

1.2、创建子模块

1.2.1、创建子模块

1.2.2、选择 Spring 初始化项目

1.2.3、添加 web 和 openfeign 依赖

1.2.4、添加模块: 通用模块、用户模块、订单模块、产品模块、仓储模块和优惠券模块

1.3、添加模块间依赖

2、导入数据库

3、逆向工程

3.1、下载人人开源的逆向工程

3.2、生成model

4、测试

4.1、导入依赖

4.2、配置

4.2.1、配置数据源;

4.2.2、配置MyBatis-Plus;

4.3、测试

5、上传码云


1、初始化微服务

1.1、创建Maven工程项目 

1.1.1、创建新的项目

1.1.2、选择 Maven 项目

1.2、创建子模块

1.2.1、创建子模块

1.2.2、选择 Spring 初始化项目

1.2.3、添加 web 和 openfeign 依赖

1.2.4、添加模块: 通用模块、用户模块、订单模块、产品模块、仓储模块和优惠券模块

1.3、添加模块间依赖

在每个模块的 pom.xml 中添加通用模块的依赖

<dependency>
	<groupId>com.atguigu.gulimall</groupId>
	<artifactId>gulimall-common</artifactId>
	<version>0.0.1-SNAPSHOT</version>
</dependency>

2、导入数据库

3、逆向工程

3.1、下载人人开源的逆向工程

码云地址: https://gitee.com/renrenio/renren-generator

3.2、生成model

3.2.1、修改数据源

3.2.2、修改生成的配置

================= 2020/05/20 添加 ===================

reason:

因为项目不使用 shiro 作为权限校验

fix:

删除 import 引入并且注释 controller 模版 shiro 注解 @RequiresPermissions()。

===============================================

4、测试

整合MyBatis-Plus

4.1、导入依赖

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.2.0</version>
</dependency>

4.2、配置

4.2.1、配置数据源;

<!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter -->
<dependency>
	<groupId>com.baomidou</groupId>
	<artifactId>mybatis-plus-boot-starter</artifactId>
	<version>3.2.0</version>
</dependency>
  • 4.2.1.2、在application.yml配置数据源相关信息

4.2.2、配置MyBatis-Plus;

  • 4.2.2.1、启动文件使用@MapperScan扫描dao层文件位置

  • 4.2.2.2、告诉MyBatis-Plus,sql映射文件位置

4.3、测试

@Test
public void contextLoads() {

	// 新增
//        BrandEntity brandEntity = new BrandEntity();
//        brandEntity.setName("华为");
//        brandService.save(brandEntity);

	// 查询
	List<BrandEntity> list = brandService.list(new QueryWrapper<BrandEntity>().eq("brand_id", 1L));
	list.forEach(System.out::println);

}

5、上传码云

gulimall_pms 商品 drop table if exists pms_attr; drop table if exists pms_attr_attrgroup_relation; drop table if exists pms_attr_group; drop table if exists pms_brand; drop table if exists pms_category; drop table if exists pms_category_brand_relation; drop table if exists pms_comment_replay; drop table if exists pms_product_attr_value; drop table if exists pms_sku_images; drop table if exists pms_sku_info; drop table if exists pms_sku_sale_attr_value; drop table if exists pms_spu_comment; drop table if exists pms_spu_images; drop table if exists pms_spu_info; drop table if exists pms_spu_info_desc; /*==============================================================*/ /* Table: pms_attr */ /*==============================================================*/ create table pms_attr ( attr_id bigint not null auto_increment comment '属性id', attr_name char(30) comment '属性名', search_type tinyint comment '是否需要检索[0-不需要,1-需要]', icon varchar(255) comment '属性图标', value_select char(255) comment '可选值列表[用逗号分隔]', attr_type tinyint comment '属性类型[0-销售属性,1-基本属性,2-既是销售属性又是基本属性]', enable bigint comment '启用状态[0 - 禁用,1 - 启用]', catelog_id bigint comment '所属分类', show_desc tinyint comment '快速展示【是否展示在介绍上;0-否 1-是】,在sku中仍然可以调整', primary key (attr_id) ); alter table pms_attr comment '商品属性'; /*==============================================================*/ /* Table: pms_attr_attrgroup_relation */ /*==============================================================*/ create table pms_attr_attrgroup_relation ( id bigint not null auto_increment comment 'id', attr_id bigint comment '属性id', attr_group_id bigint comment '属性分组id', attr_sort int comment '属性组内排序', primary key (id) ); alter table pms_attr_attrgroup_relation comment '属性&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值