# 新项目快速初始化教程
## 使用 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 创建新项目

#### 选择 Maven Archetype 项目

#### 管理添加前置步骤创建的Catalog

- 点击 `Manage catalogs`
- 1: 点击添加
- 2: 点击 `文件夹图标` 选择 `archetype-catalog.xml` 所在目录
- 3: 选择该文件夹
- 4: 点击 Add 添加
#### 填充信息创建项目
- 
- 1: 项目名称
- 2: 选择刚刚添加的 `catalog`
- 3: 选择骨架项目 `engine-archetype-web`
- 4: 配置服务启动类前缀
- 5: 配置服务基础包名
- 6: 开始创建
#### 启动项目
- 等待项目创建完成
- 启动类启动
- 使用 `test > resources > http > TestUserController.http` 测试前两个接口
- 
------
## 手工方式初始化项目
### 新建项目
#### 项目结构
- 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:
discovery:
namespace: qifu-develop
server-addr: @discovery.server-addr@
username: @discovery.username@
password: @discovery.password@
register-enabled: false
ip: ${spring.application.name}
```
### 启动测试