当前位置:网站首页>06-GuliMall 基础CRUD功能创建
06-GuliMall 基础CRUD功能创建
2022-07-16 06:13:00 【鸣鼓ming】
1.创建数据库
sql文件在这个资料包里,点击下载
创建数据库, 并导入sql数据 (直接复制粘贴sql语句执行)
先创建这5个就行

2.下载人人管理系统模板
进入人人开源仓库
下载renren-fast, renren-fast-vue, renren-generator这三个项目
- renren-fast 这个是管理系统的后端代码
- renren-fast-vue 这个是管理系统的前端代码, 用vue写的
- renren-generator 这个是代码生成器, 用来生成固定写法的代码,提高效率
解压文件
文件夹名字改一下
3.运行renren-fast管理系统
1.把renren-fast复制到gulimall工程下
复制
粘贴
这样就可以在父工程gulimall中看到该项目
聚合到父工程, 修改gulimall的pom.xml
<module>renren-fast</module>
2.数据库初始化
找到它的nysql.sql文件
创建数据库, 执行该sql
l
数据库初始化成功
3.修改配置
1.有爆红,需要指定jdk

2.修改renren-fast的application-dev.yml文件
url: jdbc:mysql://192.168.56.103:3306/gulimall-admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: root
3.运行项目
在启动类RenrenApplication上点击启动按钮启动项目
浏览器访问
http://localhost:8080/renren-fast/
访问成功

4.启动管理系统的前端
使用vscode把renren-fast-vue打开(直接拖动文件夹到vscode)
可以看到package.json文件, 其实这就类似于pom.xml, 里面写着前端项目需要的依赖
"dependencies": {
"axios": "0.17.1",
"babel-plugin-component": "0.10.1",
"babel-polyfill": "6.26.0",
"element-ui": "2.8.2",
"gulp": "4.0.2",
"gulp-concat": "2.6.1",
"gulp-load-plugins": "2.0.5",
"gulp-replace": "1.0.0",
"gulp-shell": "0.8.0",
"lodash": "4.17.5",
"node-sass": "^6.0.1",
"npm": "^6.9.0",
"sass-loader": "6.0.6",
"svg-sprite-loader": "3.7.3",
"vue": "2.5.16",
"vue-cookie": "1.1.4",
"vue-router": "3.0.1",
"vuex": "3.0.1"
}
使用终端命令下载依赖(再此之前记得要装node.js, 运行vue项目需要这个)
先设置一个淘宝镜像仓库,下载更快
以管理员身份打开windows 的cmd,执行命令
npm config set registry https://registry.npm.taobao.org --global

在vscode终端执行命令, 下载依赖
npm install

在vscode终端执行命令, 运行项目
npm run dev

访问 http://localhost:8001

账号密码都是admin

4.使用renren-generator
把renren-generator导入到父工程gulimall, 操作和上面一样,不解释了
使用renren-generator为商品服务gulimall_product模块生成代码
需要修改renren-generator和配置
# 改成8090, 因为80端口容易被占用
server:
port: 9080
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
#MySQL配置
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.56.103/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: rootot
注释模板文件Controller.java.vm中的所有@RequiresPermissions, 这个功能暂时不用
代码的生成策略就是由这些模板文件制定的
并且注释一个导包语句
//import org.apache.shiro.authz.annotation.RequiresPermissions;
需修改generator.properties的内容如下
#代码生成器,配置信息
mainPath=com.atguigu
#包名
package=com.atguigu.gulimall
moduleName=product
#作者
author=lm
#Email
email=lm-[email protected].com
#表前缀(类名不会包含表前缀)
tablePrefix=pms_
启动代码生成器项目, 浏览器访问
http://localhost:9080/

全部选中, 点击生成代码
会下载一个压缩包
解压后把压缩包里对应main文件夹直接复制粘贴到gulimall_product模块
可以看到有报错, 下面我们来解决
5.创建公共模块gulimall-common
在父工程gulimall下创建模块gulimall-common




修改gulimall-common的pom.xml文件
<?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.atguigu.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>
<!-- 导入mysql驱动 -->
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
<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>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
</dependencies>
</project>
看看renren-fast模块
从renren-fast里复制以下文件到gulimall-common

6.引入公共模块gulimall-common
首先修改商品服务模块gulimal-product
引入依赖
<dependency>
<groupId>com.atguigu.gulimall</groupId>
<artifactId>gulimall-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
SpringBoot的版本改一下, 和网课里的一致,避免出现麻烦
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
修改application.properties配置文件,连接数据库
server.port=9080
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.56.103/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=root
mybatis-plus.mapper-locations=classpath:/mapper/**/*.xml
mybatis-plus.global-config.db-config.id-type=auto
启动商品服务项目
如果出现以下报错,请clean, install一下公共依赖模块就行了

访问
http://localhost:9080/product/attrattrgrouprelation/list

其它微服务模块也是同样的操作,不多说了
边栏推荐
- 5. Redis architecture design to usage scenario - storage principle - data type infrastructure
- How to solve the problem of high concurrency? You will understand it completely after reading it.
- Simple function relation
- 小程序毕设作品之微信评选投票小程序毕业设计(6)开题答辩PPT
- Top k high frequency elements
- Xsslabs customs clearance
- 数据敏捷,HTAP数据库既决效率又决生死
- 为什么电商平台要重点关注非法经营罪,这与二清又有什么关联?
- 全排序问题
- Altium designer schematic generation PCB
猜你喜欢

Kotlin | launch build report for kotlin compiler task

mitmproxy 入门安装

Design of combustible gas smoke system based on single chip microcomputer (0488)

Family tree problem

The degradation mechanism is not designed properly, and the online system crashes instantly

微机原理与技术接口 实验三 循环结构

Codeforces Round #804 A The Third Three Number Problem

深度学习(2020李宏毅)学习记录

thinkphp5.1.37反序列化链子分析

5. Redis architecture design to usage scenario - storage principle - data type infrastructure
随机推荐
XGBoostError: [10:19:14] C:\dev\libs\xgboost\src\objective\objective. cc:23:
How about the income of increased life insurance? Can it be a pension financial product?
Introduction to common controls of C form application
Compilation basis CTF
分库分表和 NewSQL 到底怎么选?
Will IO always occupy CPU? A good question about concurrent / parallel systems (turn)
C#窗体应用程序常用控件介绍
LeetCode(剑指 Offer)- 03. 数组中重复的数字
5. Redis architecture design to usage scenario - storage principle - data type infrastructure
基于单片机的氢气监测系统设计(#0491)
Codeforces Round #805 A - G
微机原理与技术接口 实验三 循环结构
【C语言】printf格式化输出及修饰符总结
Tens of billions of data were compressed to 600gb, and tdengine was launched on GCL energy mobile energy platform
Eureka read-write lock fantasy, too top!
HMS core graphics and image technology shows the latest functions and application scenarios, and accelerates the construction of digital intelligence life
Please ask a question: does the flinkcdc need root permission to synchronize MySQL data?
How to turn off win11 system protection? Win11 system protection shutdown method
Codeforces Global Round 21 C. Fishingprince Plays With Array
Conditional ternary operator...