From 070acb0251ea9c13a7e64c9d175e890590756c6d Mon Sep 17 00:00:00 2001 From: liuxiaohua Date: Tue, 27 May 2025 10:47:04 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20[2025-05-27]=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=96=B0=E9=A1=B9=E7=9B=AE=E5=BF=AB=E9=80=9F=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=95=99=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../基础组件/20250527-新项目快速初始化教程.md | 253 ++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 文档/基础组件/20250527-新项目快速初始化教程.md diff --git a/文档/基础组件/20250527-新项目快速初始化教程.md b/文档/基础组件/20250527-新项目快速初始化教程.md new file mode 100644 index 0000000..5ae5909 --- /dev/null +++ b/文档/基础组件/20250527-新项目快速初始化教程.md @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + +# 新项目快速初始化教程 + +## 使用 Maven Archetype 初始化项目(建议) +### 前置配置步骤 +#### 添加私服骨架配置文件 +- 建议在本地仓库根目录添加 +- 存在则增量添加 `archetype` +```xml + + + + + com.yuanmeng.engine + engine-archetype-web + 2.0.0-SNAPSHOT + Parent pom providing dependency and plugin management for applications built with Maven + + + + +``` + +### IDEA 新建项目 +#### IDEA 点击 New Project 创建新项目 +![](https://picture.texous.cn/blog/20250527100709361.png) +#### 选择 Maven Archetype 项目 +![](https://picture.texous.cn/blog/20250527100806729.png) +#### 管理添加前置步骤创建的Catalog +![](https://picture.texous.cn/blog/20250527101058992.png) +- 点击 `Manage catalogs` +- 1: 点击添加 +- 2: 点击 `文件夹图标` 选择 `archetype-catalog.xml` 所在目录 +- 3: 选择该文件夹 +- 4: 点击 Add 添加 + +#### 填充信息创建项目 +- ![](https://picture.texous.cn/blog/20250527101544423.png) + - 1: 项目名称 + - 2: 选择刚刚添加的 `catalog` + - 3: 选择骨架项目 `engine-archetype-web` + - 4: 配置服务启动类前缀 + - 5: 配置服务基础包名 + - 6: 开始创建 + + +#### 启动项目 +- 等待项目创建完成 +- 启动类启动 +- 使用 `test > resources > http > TestUserController.http` 测试前两个接口 +- ![](https://picture.texous.cn/blog/20250527104138665.png) + +------ + +## 手工方式初始化项目 + +### 新建项目 + +#### 项目结构 + +- qifu-saas-xxx + - qifu-saas-xxx-client + - qifu-saas-xxx-service + +### 引入需要的功能包 + +#### qifu-saas-xxx > pom.xml + +```xml + + + 4.0.0 + + com.yuanmeng.qifu + qifu-saas-parent + 2.0.0-SNAPSHOT + + + qifu-saas-xxx + ${revision} + pom + qifu-saas-xxx + + + qifu-saas-xxx-client + qifu-saas-xxx-service + + + + + 0.0.1-SNAPSHOT + 0.0.1-SNAPSHOT + + + + + development + + true + + + + + + production + + + 0.0.1 + 0.0.1 + + + + + + + + com.yuanmeng.qifu + qifu-saas-xxx-client + ${qifu.saas.xxx.client.version} + + + + + +``` + +#### qifu-saas-xxx-client > pom.xml + +```xml + + + 4.0.0 + + com.yuanmeng.qifu + qifu-saas-xxx + ${revision} + + qifu-saas-xxx-client + + + com.yuanmeng.engine + engine-starter-feign + + + +``` + +#### qifu-saas-xxx-service > pom.xml + +```xml + + + 4.0.0 + + com.yuanmeng.qifu + qifu-saas-xxx + ${revision} + + + qifu-saas-xxx-service + + + + com.yuanmeng.qifu + qifu-saas-xxx-client + + + + com.yuanmeng.engine + engine-starter-web + + + + + +``` + +### 编写启动类 + +```java + +@EnableFeignClients(basePackages = {"com.yuanmeng.*"}) +@EnableDiscoveryClient +@SpringBootApplication +public class QifuSaasEgApplication { + + public static void main(String[] args) { + SpringApplication.run(QifuSaasEgApplication.class, args); + } + +} +``` + +### 编写配置文件 + +- `bootstrap.yml` + +```yaml +server: + port: 10000 +spring: + application: + name: qifu-saas-xxx + + cloud: + # nacos 配置本地不需要,别的环境会使用运维版本,不需要自己维护 + nacos: + discovery: + namespace: qifu-develop + server-addr: @discovery.server-addr@ + username: @discovery.username@ + password: @discovery.password@ + register-enabled: false + ip: ${spring.application.name} + # config: + # namespace: @config.namespace@ + # server-addr: @discovery.server-addr@ + # username: @discovery.username@ + # password: @discovery.password@ + # file-extension: yml + # config-retry-time: 30000 + +``` + +### 启动测试 \ No newline at end of file