尚硅谷-谷粒商城-个人学习笔记【环境搭建篇】

部份环境搭建重新写了篇独立文章,传送门在面!省事的小伙伴可以直接按步骤复制粘贴执行确保百分百成功!
CentOs安装Docker
Docker安装Mysql
Docker安装Redis

在本地使用sql工具连接到我们服务器中的mysql后,分别建立以下数据库并且导入数据:
gulimall_oms
gulimall_pms
gulimall_sms
gulimall_ums
gulimall_wms

项目服务的搭建

首先我们创建一个空的java项目,在此项目中挨个来构建我们的各个微服务:
优惠卷服务————gulimall-coupon
会员服务————gulimall-member
订单服务————gulimall-order
商品服务————gulimall-product
仓储服务————gulimall-ware

创建每个微服务的步骤如下,注意模块名称与统一包名:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
创建完成后,各个微服务都有自身的pom文件,复制其任意一个,放在主目录项目下。该pom文件与模块同级,并对其内容进行修改,详情看图中注释:
在这里插入图片描述
创建一个common模块,用来存储该项目中公共的资源。例如依赖、工具类等等
在这里插入图片描述

在这里插入图片描述
该公共模块pom文件这里直接贴出来,大家复制粘贴后改一下里面的artifactId,groupId即可

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>gulimall</artifactId>
        <groupId>com.lc.gulimall</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>gulimall-common</artifactId>
    <description>公共</description>

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

        <!--        lombok-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.8</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.12</version>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>

        <!--        mysql-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.17</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>

在这里插入图片描述

页面与后台代码我们使用人人开源中的项目来:人人开源
在这里插入图片描述
将这三个项目下载到本地后导入到自己项目中,其中renren-fast为我们的后台代码,renren-generator是用来生成基础的curd代码的工具类,renren-fast-vue为前端代码。这里前端代码不做演示,下载到本地后直接运行即可。
导入项目后,renren-fast项目中有db文件夹。复制自己使用的数据库语句,本地创建数据后执行该语句即可。这里跟着视频教学走,数据库名称为gulimall_admin。执行完结果如下:
在这里插入图片描述
随后修改renren-fast中application-dev.yml中的配置。修改数据库连接地址账号密码即可。
准备好之后启动renren-fast项目与renren-fast-vue项目。进入登录页面,默认账号密码都为admin。
在这里插入图片描述

生成基础CURD代码:

生成前需要修改一下controller的模板,因为有些注解我们这次项目用不上,具体如图:
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
修改好配置后,进入如下页面:具体操作看图中注释:
在这里插入图片描述
将生成的压缩包解压后,替换相同模块下的文件即可。
在这里插入图片描述
这里需要仔细看下resources下,删掉了src目录,因为暂时不用那些东西
每个模块的配置文件都需要做相应的修改,这里需要细心哦

配置文件的修改:

这里需要修改每个模块的pom文件,引入我们之前写好的common模块即可:

		<dependency>
			<groupId>xx.xxx</groupId>
			<artifactId>gulimall-common</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
导入完成后,代码是直接报错的,需要看下图导入一下代码。来源于renren-fast目录下,把图中导入的7各类复制进来即可

在这里插入图片描述
到此为止,这个项目的基础各个模块已经生成。对于每个模块的端口号,可以参考视频中,这里贴出运行结果图!
大功告成图

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
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、付费专栏及课程。

余额充值