四、人人开源

一、整合人人开源

1.整合人人开源

  1. gitee搜索人人开源,找到renren-fast,在克隆 / 下载那里 复制https,
    打开git 的 git bash here ,使用命令 git clone https://gitee.com/renrenio/renren-fast.git
    在找到 renren-fast-vue ,在克隆 / 下 载那里 复制https, 使用命令git clone https://gitee.com/renrenio/renren-fast-vue.git
  2. 删掉下载的这两个文件夹里面的git
    快捷键打开idea项目文件夹
    在这里插入图片描述
  3. 将renren-fast 文件夹托到项目的根目录,并在总项目的pom.xml里加入 <module>renren-fast</module>
  4. 打开sqlyog,创建数据库gulimall_admin,将renren-fast文件下的db的sql文件复制到sqlyog,全选以后执行导入
  5. 修改renren-fast的application-dev.yml文件:修改数据库连接地址以及账号密码 ,运行程序
url: jdbc:mysql://192.168.56.10:3306/gulimall_admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: root 
  1. 用webStorm打开renren-fast-vue,先安装node.js ,官网下载http://nodejs.cn/api/ ,进行安装 ,使用命令 node -v 检查,
    配置npm淘宝镜像:npm config set registry http://registry.npm.taobao.org/
    在前端项目让maven下载依赖的组件 npm install ,如果失败,去git下载人人开源的vue的zip文件 ,再npm install 成功后,npm run dev
    默认登录账号密码:admin admin
  2. 代码生成器,去git下载人人开源renren-generator, 打开git 的 git bash here ,打开git的使用命令:https://gitee.com/renrenio/renren-generator.git
  3. 将文件夹放到根目录,把.git文件夹删掉,在根项目的pom.xml加入renren-generator-master 或 renren-generator
    使用代码生成器:(1)改application.yml文件中的数据库信息:
 url: jdbc:mysql://192.168.56.10:3306/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: root

(2)generator.properties 修改:

mainPath=com.atguigu  #主目录
package=com.atguigu.gulimall  #包名
moduleName=product #模块名
author=gys #作者
email=  #Email
tablePrefix=pms_  #表前缀(类名不会包含表前缀)

(3)将resources下template下的controller中的所有requiresPermissions注解注释掉

##import org.apache.shiro.authz.annotation.RequiresPermissions;
 ##    @RequiresPermissions("${moduleName}:${pathName}:info")
  1. 启动代码生成器的main方法,访问:http://localhost/#generator.html在这里插入图片描述

  2. 在页面的renren-fast全部勾选在这里插入图片描述

  3. 会将代码生成一个压缩包,打开解压的文件,将main文件粘贴到对应的微服务模块里,会多出来一些内容,不要删掉之前存在的main文件。把resource下的src文件夹删掉,里面是vue文件。

  4. 建一个公共模块 ,将每一个微服务公共的内容放在这个模块,shift+F6 修改模块名 rename module
    在这里插入图片描述
    在这里插入图片描述
    在pom.xml中加入 <description>每一个微服务公共的依赖,bean,工具类等</description>

  5. 在product项目的pom.xml加入,增加application.yml文件,改端口号

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

二、公共模块

1.公共模块

1)建包com/atguigu/common/utils、 com/atguigu/common/xss
将人人项目下的工具类PageUtils、Query、Constant、R、RRException 复制到untis包。将HTMLFilter、SQLFilter复制到xss包

2.公共模块的pom.xml增加内容

 <description>每一个微服务公共的依赖,bean,工具类等</description>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>7</source>
                    <target>7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <!--         mybatis-plus -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.2.0</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>
        <!--     导入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>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <!--         服务注册/发现 -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <!--         配置中心来做配置管理 -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>2.0.1.Final</version>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>2.1.0.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

3.整合mybatis-plus

1.导入依赖 (公共模块)

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

2.配置
1)配置数据源
jar包下载
(1)导入数据库驱动 (公共模块)
例如:(公共模块)

      <!--     导入mysql驱动     -->
        <!--  https://mvnrepository.com/artifact/mysql/mysql-connector-java  -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.17</version>
        </dependency>

(2)在application.yml文件配置数据源信息、指定端口号 (业务模块)
例如:在product模块,创建application.yml文件,内容:

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.56.10:3306/gulimall_pms
    driver-class-name: com.mysql.jdbc.Driver
server:
  port: 10000

2)配置mybatis-plus
1)使用@MapperScan
例如:在启动类加注解:@MapperScan(“com.atguigu.gulimall.product.dao”)
2)告诉mybatis-plus sql映射文件
例如: 在product模块的application.yml加内容:

mybatis-plus:
  mapper-locations: classpath:/mapper/**/*.xml
  global-config:
    db-config:
      id-type: auto
      logic-delete-value: 1
      logic-not-delete-value: 0

4、逆向生成所有微服务基本CRUD代码

在其他的项目的pom.xml引入公共模块,增加application.yml文件,改端口号

  1. pom.xml引入公共模块
<dependency>
          <groupId>gulimall</groupId>
          <artifactId>gulimall-common</artifactId>
          <version>0.0.1-SNAPSHOT</version>
</dependency>
  1. 人人开源renren-generator 项目
    1)改application.yml文件中的数据库信息:
    优惠服务coupon:
 url: jdbc:mysql://192.168.56.10:3306/gulimall_sms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: root

会员服务member:

 url: jdbc:mysql://192.168.56.10:3306/gulimall_ums?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: root

订单服务order:

 url: jdbc:mysql://192.168.56.10:3306/gulimall_oms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: root

库存服务ware:

 url: jdbc:mysql://192.168.56.10:3306/gulimall_wms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: root

(2)generator.properties 修改:
优惠服务coupon:

mainPath=com.atguigu  #主目录
package=com.atguigu.gulimall  #包名
moduleName=coupon #模块名 
tablePrefix=sms_  #表前缀(类名不会包含表前缀)

会员服务member:

mainPath=com.atguigu  #主目录
package=com.atguigu.gulimall  #包名
moduleName=member #模块名 
tablePrefix=ums_  #表前缀(类名不会包含表前缀)

订单服务order:

mainPath=com.atguigu  #主目录
package=com.atguigu.gulimall  #包名
moduleName=order #模块名 
tablePrefix=oms_  #表前缀(类名不会包含表前缀)

库存服务ware:

mainPath=com.atguigu  #主目录
package=com.atguigu.gulimall  #包名
moduleName=ware #模块名 
tablePrefix=wms_  #表前缀(类名不会包含表前缀)

(3)将resources下template下的controller中的所有requiresPermissions注解注释掉

##import org.apache.shiro.authz.annotation.RequiresPermissions;
 ##    @RequiresPermissions("${moduleName}:${pathName}:info")

(4)启动 人人开源renren-generator 启动类 ,点IDEA启动类的80端口,进入http://localhost/#generator.html,点页面的renren-fast,页面条数调大才能选中所有表,点“生成代码”按钮。
在这里插入图片描述
在这里插入图片描述
(5)解压生成的文件,复制main文件夹,粘贴到对应微服务项目的main文件夹,会多一些内容。
在这里插入图片描述
(6)删掉resource文件夹下面的src文件夹
(7)创建application.yml文件,改数据库名、端口号
优惠服务coupon:

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.56.10:3306/gulimall_sms
    driver-class-name: com.mysql.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: 7000

会员服务member:

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.56.10:3306/gulimall_ums
    driver-class-name: com.mysql.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: 8000

订单服务order:

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.56.10:3306/gulimall_oms
    driver-class-name: com.mysql.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

库存服务ware:

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.56.10:3306/gulimall_wms
    driver-class-name: com.mysql.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: 11000
  1. 启动 测试
    优惠服务coupon:
    http://localhost:7000/coupon/coupon/list

会员服务member:
http://localhost:8000/member/growthchangehistory/list

订单服务order:
http://localhost:9000/order/order/list

库存服务ware:
http://localhost:11000/ware/purchase/list

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
人人开源是一个基于Spring Boot和Vue.js的开源后台管理系统,可以用于快速搭建企业级Java后端管理系统的基础框架。搭建人人开源后台管理系统的步骤如下: 1. 首先,将项目上传到自己的码云(gitee.com)中。在码云中创建一个名为"renren-fast-vue"的仓库。 2. 在本地执行以下脚本,将项目上传到创建的仓库中: ``` cd renren-fast-vue # 进入项目根目录 git init # 初始化Git仓库 git add . # 添加所有文件到Git git commit -m "first commit" # 提交第一次的更改 git remote add origin [email protected]:你的用户名/renren-fast-vue.git # 与远程仓库建立连接 git push -u origin master # 将代码推送到远程仓库 ``` 3. 接下来,创建一个名为"common"的模块,用于存放项目中需要的公共实体类和依赖。 4. 把项目中缺少实体类或依赖的部分放入"common"模块中。这样,其他微服务模块就可以依赖"common"模块来获取实体类和依赖。 5. 类似地,将配置文件也放入"common"模块中,这样每个微服务模块就不需要手动添加配置了。只需要依赖"common"模块,就可以获取到放入"common"模块中的配置。 通过以上步骤,你就可以成功搭建人人开源的后台管理系统,并且实现了公共实体类和依赖的共享,以及公共配置的集中管理。这样可以提高开发效率和代码的维护性。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [使用【人人开源】搭建后台管理系统](https://blog.csdn.net/weixin_32196893/article/details/118851423)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [人人开源搭建后台管理系统 & 逆向工程生成CRUD代码](https://blog.csdn.net/lwj_07/article/details/127832166)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值