使用archetype生成微服务模块 === >[info] Version: 3.4+ 本文旨在:通过命令快速生成新微服务模块 ## 生成新模块 通过`mvn` 命令生成微服务模块 `jeecg-module-erp` 重要:`包名规则 org.jeecg.modules.* ` 不要改,不然bean扫描不到! ## mvn命令 ``` //注意:windows下可直接复制执行, Linux/Macos下 ^ 修改成 \ mvn archetype:generate ^ -DgroupId=org.jeecg.modules.erp ^ -Dmodule=erp^ -Dmodule-up-first=Erp^ -DartifactId=jeecg-module-erp ^ -Dversion=3.4.0^ -DarchetypeGroupId=org.jeecgframework.archetype ^ -DarchetypeArtifactId=jeecg-cloud-gen ^ -DarchetypeVersion=3.4.0 ``` >[warning]重要提醒: > - DarchetypeVersion版本号是固定的不要改 > - 3.3之前的老版本用这个 [老文档](http://doc.jeecg.com/2194069) ## 集成步骤 ### 一、生成项目结构 ![](https://img.kancloud.cn/c2/2a/c22a3b928b3a6eddc25f8831cbcf565d_410x207.png) ### 二、如何启动项目 1. 修改启动端口 - 端口位置:`jeecg-module-{模块名}-start/application.yml` 的属性 `server.port` 通过IDEA右键运行: `jeecg-module-{模块名}-start/org.jeecg.Jeecg{模块名}CloudApplication`启动项目 访问服务模块接口地址:http://127.0.0.1:{端口} ![](https://img.kancloud.cn/2e/df/2edf65a118241b42e2e3560ecd567435_1089x590.png =850x450) 2. 通过命令启动模块 >[info] 提醒:前提需要把`jeecg-boot-parent` install到本地仓库中。 ~~~ cd jeecg-module-{模块名} mvn clean install cd jeecg-module-{模块名}-start\target java -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jeecg-module-{模块名}-start.jar ~~~ 启动成功 ![](https://img.kancloud.cn/cd/56/cd56a0674c273ac4ee01eb892e252346_873x924.png =500x500) 在nacos发现此服务 ![](https://img.kancloud.cn/4c/d3/4cd3b175fe66393ff89a0c28453f2e54_1293x645.png) 3. 添加路由网关 进入系统监控 - 路由网关 菜单 ![](https://img.kancloud.cn/cf/b3/cfb3ee7825e4b4bc43f6d6accc19fcf7_2545x633.png) 点击新增微服务模块 ![](https://img.kancloud.cn/f6/31/f6318aa28a31a86778e409454c4514cd_486x658.png) 4. 访问gateway地址 >[info] 通过gateway看到生成的新模块,就说明配置网关生效了,下面就可以玩服务之间接口互调了。 ![](https://img.kancloud.cn/da/45/da45b426073ea0345444cf4d16ca5321_889x592.png =800x500) 5. 如果需要调用system模块的api,请引入 ~~~ <!--system cloud api--> <dependency> <groupId>org.jeecgframework.boot</groupId> <artifactId>jeecg-system-cloud-api</artifactId> </dependency> ~~~ *****