使用人人开源快速开发
使用人人开源快速开发
1.1人人开源搭建后台管理系统
(1)clone
$ git clone git@gitee.com:renrenio/renren-fast-vue.git
$ git clone git@gitee.com:renrenio/renren-fast.git
(2)复制到项目中
<modules>
<module>gulimail-product</module>
<module>gulimall-coupon</module>
<module>gulimall-member</module>
<module>gulimall-order</module>
<module>gulimall-ware</module>
<module>renren-fast</module>
</modules>
(3)执行mysql
(4)修改启动端口号(默认80,容易冲突)和数据库连接地址
server:
port: 8888
url: jdbc:mysql://192.168.56.10:3306/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
(5)运行
1.2 搭建前端环境
(1)安装node
地址:https://nodejs.org/zh-cn/download/
下载后选择安装地址(不建议c盘),一路next即可
检查node版本
node -v
设置npm镜像地址
npm config set registry http://registry.npm.taobao.org/
(2)前后联调
项目安装npm
npm install
启动
npm run dev
访问http://localhost:8001/#/login
输出用户名admin密码admin 验证码,登录成功,前后端联调成功
1.3逆向工程搭建&使用
(1)下载代码人人开源代码生成器
$ git clone git@gitee.com:renrenio/renren-generator.git
(2)renren-generator加载到项目中
(3)修改mysql数据库相关配置
url: jdbc:mysql://192.168.10.56:3306/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
(4)修改代码生成配置
# 主目录
mainPath=com.peng
#包名
package=com.peng.gulimall
moduleName=product
#作者
author=peng
#Email
email=pengpeng6135@163.com
#表前缀(类名不会包含表前缀)
tablePrefix=pms_
(5)修改contoller模板
注释import org.apache.shiro.authz.annotation.RequiresPermissions命名空间
注释Controller.java.vm模板中所有的@RequiresPermissions("${moduleName}😒{pathName}:list")
(6)新建公共模块
新建模块
选择maven项目
新建gulimall-common
配置gulimall-common的pom.xml
<parent>
<artifactId>gulimall</artifactId>
<groupId>com.peng.gulimall</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<artifactId>gulimall-common</artifactId>
<description>每一个微服务公共的的依赖、bean、工具类</description>
gulimall-common添加到pom.xml
(7)gulimall-common依赖
<dependencies>
<!-- mybatisPLUS -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
<!--简化实体类,用@Data代替getset方法-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
</dependency>
<!-- httpcomponent包 -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.13</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- 数据库驱动 https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version>
</dependency>
</dependencies>
(8)启动,访问 http://localhost:8888/#generator.html
(9)生成代码
(10)生成的代码复制到项目中去
1.4测试基本基本的CRUD功能
(1)整合MyBatis-Plus
<!-- mybatisPLUS -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
(2)@MapperScan配置注入的数据访问层
(3)配置application.yml
spring:
datasource:
username: root
password: root
url: jdbc:mysql://192.168.56.10:3306/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.jdbc.Driver
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
db-config:
id-type: auto
(4)测试
1.5 所有微服务的CURD(例子)
- 商品服务product
- 存储服务ware
- 订单服务order
- 优惠券服务coupon
- 用户服务member
如果UndoLog的有关服务报错,可以都先注释掉,暂时用不上
1.5.1 coupon 优惠卷服务
renren-generator工程,修改generator.properties
#主目录
mainPath=com.peng
#包名
package=com.peng.gulimall
#模块名
moduleName=coupon
#作者
author=peng
#email
email=pengpeng6135@163.com
#表前缀(类名不会包含表前缀) # 我们的sms数据库中的表的前缀都sms
如果写了表前缀,每一张表对于的javaBean就不会添加前缀了
tablePrefix=sms_
renren-generator工程,修改application.yml数据库信息
server:
port: 8888
# mysql
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
#MySQL配置
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.56.10:3306/gulimall_sms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
gulimall-coupon工程,依赖于common,修改pom.xml
<dependency>
<groupId>com.peng.gulimall</groupId>
<artifactId>gulimall-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
gulimall-coupon工程,修改application.yml数据库配置
spring:
datasource:
username: root
password: root
url: jdbc:mysql://192.168.56.10:3306/gulimall_sms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
db-config:
id-type: auto
logic-delete-value: 1
logic-not-delete-value: 0
server:
port: 7001
运行gulimallCouponApplication.java
访问http://localhost:8888/#generator.html
生成完的代码赋值到gulimall-coupon,以下是项目结构
配置mapper映射,并启动
@MapperScan("com.peng.gulimall.coupon.dao")
测试gulimall-coupon,访问http://localhost:7001/coupon/coupon/list
1.5.2 member 用户服务
(1)renren-generator修改generator.properties
#模块名
moduleName=member
#表前缀(类名不会包含表前缀) # 我们的ums数据库中的表的前缀都ums
如果写了表前缀,每一张表对于的javaBean就不会添加前缀了
tablePrefix=ums_
(2)renren-generator修改application.yml
url: jdbc:mysql://192.168.56.10:3306/gulimall_ums?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
(3)gulimall-member修改pom.xml
<dependency>
<groupId>com.peng.gulimall</groupId>
<artifactId>gulimall-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
(4)gulimall-member修改application.yml
spring:
datasource:
username: root
password: root
url: jdbc:mysql://192.168.56.10:3306/gulimall_ums?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
db-config:
id-type: auto
logic-delete-value: 1
logic-not-delete-value: 0
server:
port: 8002
(5)入口增加mapper映射
(6)访问:http://localhost:8002/member/growthchangehistory/list
1.5.3 order 订单服务
(1)renren-generator修改generator.properties
#模块名
moduleName=order
#表前缀(类名不会包含表前缀) # 我们的oms数据库中的表的前缀都oms
如果写了表前缀,每一张表对于的javaBean就不会添加前缀了
tablePrefix=oms_
(2)renren-generator修改application.yml
url: jdbc:mysql://192.168.56.10:3306/gulimall_oms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
(3)gulimall-member修改pom.xml
<dependency>
<groupId>com.peng.gulimall</groupId>
<artifactId>gulimall-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
(4)gulimall-member修改application.yml
spring:
datasource:
username: root
password: root
url: jdbc:mysql://192.168.56.10:3306/gulimall_oms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
db-config:
id-type: auto
logic-delete-value: 1
logic-not-delete-value: 0
server:
port: 9000
(5)入口增加mapper映射
@MapperScan("com.peng.gulimall.order.dao")
(6)访问:http://localhost:9000/order/mqmessage/list
1.5.4 ware 存储服务
(1)renren-generator修改generator.properties
#模块名
moduleName=ware
#表前缀(类名不会包含表前缀) # 我们的wms数据库中的表的前缀都wms
如果写了表前缀,每一张表对于的javaBean就不会添加前缀了
tablePrefix=wms_
(2)renren-generator修改application.yml
url: jdbc:mysql://192.168.56.10:3306/gulimall_wms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
(3)gulimall-member修改pom.xml
<dependency>
<groupId>com.peng.gulimall</groupId>
<artifactId>gulimall-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
(4)gulimall-member修改application.yml
spring:
datasource:
username: root
password: root
url: jdbc:mysql://192.168.56.10:3306/gulimall_wms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.cj.jdbc.Driver
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
db-config:
id-type: auto
logic-delete-value: 1
logic-not-delete-value: 0
server:
port: 10000
(5)入口增加mapper映射
@MapperScan("com.peng.gulimall.ware.dao")
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!