跳至主要內容

生成所有微服务的CRUD代码

悟空项目实战passjava面试刷题项目约 391 字大约 1 分钟...

文档在线地址:www.passjava.cnopen in new window

生成五大微服务的CRUD代码

1. 修改代码生成器配置文件

(1)\renren-generator\src\main\resources\generator.properties

mainPath=com.jackson0714
package=com.jackson0714.passjava
moduleName=channel
author=jackson0714
email=jackson0585@163.com
tablePrefix=chms_

(2)\renren-generator\src\main\resources\application.yml

修改连接的数据库:passjava_chms

2.生成渠道微服务代码

启动服务,打开浏览器:http://localhost:8003/#generator.htmlopen in new window

注意:端口地址默认是8080,我配置成了8003。

生成渠道微服务代码
生成渠道微服务代码

3.添加生成的代码

  • 删除自动生成的代码中的文件夹:main\resources\src
  • 拷贝main文件夹到channel模块src目录下

4.配置渠道微服务

  • pom.xml引入common模块

    <dependency>
        <groupId>com.jackson0714.passjava</groupId>
        <artifactId>passjava-common</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    
  • 添加application.yml

    spring:
      datasource:
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://129.211.188.xxx:3306/passjava_chms?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
          username: root
          password: xxx
    
    mybatis-plus:
      mapper-locations: classpath:/mapper/**/*.xml
      global-config:
        db-config:
          id-type: auto
    
  • 5.测试channel服务接口

    访问:http://localhost:8000/channel/channel/listopen in new window

    返回:

    {"msg":"success","code":0,"page":{"totalCount":0,"pageSize":10,"totalPage":0,"currPage":1,"list":[]}}
    

5.生成所有微服务的CRUD代码

生成所有微服务代码
生成所有微服务代码

6.配置微服务端口

passjava-channel  端口8000
passjava-content  端口9000
passjava-member 端口10000
passjava-question 端口11000
passjava-study 端口12000

所有微服务都启动成功并测试接口通过

http://localhost:8000/channel/channel/list
http://localhost:9000/content/banner/list
http://localhost:10000/member/member/list
http://localhost:11000/question/question/list
http://localhost:12000/study/studytime/list
mark
mark

代码地址

https://github.com/Jackson0714/PassJava-Platformopen in new window

公众号

公众号
公众号
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.3.0