# yfcloud-repo-example
**Repository Path**: osswork/yfcloud-repo-example
## Basic Information
- **Project Name**: yfcloud-repo-example
- **Description**: 组件库范例
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: 1.0.0-dev
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 2
- **Created**: 2022-09-22
- **Last Updated**: 2022-09-22
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# yfcloud-repo-example
## 一、快速上手 quick-start
#### 1. 启动范例项目
* 组件库范例仓库地址:https://gitee.com/yfclouds/yfcloud-repo-example/tree/1.0.0-dev/
* 定位启动类:com.yifeng.repo.example.ApplicationStartUp
* 设置启动参数
```text
-Dserver.port=8081
-Dapp_id=yfcloud-example
-Dapp_stage=develop
-Dapp_ver=1.0.0
-Dapp_conf=http://139.9.50.212:8848
-Dconf_username=test_dev
-Dconf_password=******(mask)
-Dspring.cloud.bootstrap.enabled=true
温馨提示:请使用自己申请的帐号密码来启动。
```
* 在Nacos配置启动参数
```text
write.url=jdbc:mysql://192.168.254.37:59003/yfcloud_example?allowMultiQueries=true&serverTimezone=Asia/Shanghai
write.user=yfcloud_example
write.password=******(mask)
温馨提示:请使用自己申请的帐号密码来写数据库。
```
* 启动服务后就可以发起请求(更多的在api模块的resources目录下的*.http文件里面)
```http request
### 分页查询菜单数据,根据appId查询
GET http://127.0.0.1:8081/yfcloud-example/rpc/rpcSys/list?appId=2
```
## 二、框架库 frameworks
| 编号 | 名称 | 功能 | 说明 |
| :----: |:-----------------------------:| :----: | :---- |
| 1 | frameworks-base | 框架基础 | Base 是核心模块,提供最基础的框架能力 |
| 2 | frameworks-mybatis-starter | Mybatis+Mybatis plus增强 | Mybatis 提供数据层的应用能力 |
| 3 | frameworks-interfaces-starter | 接口工程 | Interface 提供接口管理能力 |
| 4 | frameworks-fsm-starter | 状态机 | FSM 提供状态机能力 |
| 5 | frameworks-xml-excel | 导出excel | EXCEL 提供Excel报表数据导出能力 |
| 6 | frameworks-redis-starter | redis分布式缓存 | 支持通过注解和命令的方式操作缓存 |
* 框架库仓库地址:https://gitee.com/yfclouds/frameworks/tree/2.0.9.yf/
* 温馨提示:超级外援提供的的是2.0.9-dev,基础产品研发适配益丰的版本是2.0.9.yf
## 三、组件库 yfcloud-repo
| 编号 | 名称 | 功能 | 说明 |
| :----: | :----: | :----: |:-------------------------------------------------------------------|
| 1 | yfcloud-base-parent | 基础pom | 新建项目建议继承该parent作为pom基础 |
| 2 | yfcloud-base-utils | 基础工具类 | 整合多年沉淀积累的工具类 |
| 3 | yfcloud-micro-service-starter-server | 微服务服务端starter | 新建项目建议依赖该starter作为服务端项目基础,
当前已经支持OSS、SSO、MPS、消息中心、
以及批量读和写多源数据库 |
| 4 | yfcloud-storage-starter-redis | redis分布式缓存 | 支持轻量级直接操作redis,建议使用frameworks-redis-starter |
| 5 | yfcloud-storage-starter-elasticsearch | ES搜索 | ES搜索的常用操作的最佳实践 |
| 6 | yfcloud-storage-starter-clickhouse | CK分析型数据库 | 未完成 |
| 7 | yfcloud-service-gateway-traffic | 业务网关流量控制 | 入口流量和出口流量管控 |
| 8 | yfcloud-service-gateway-request | 业务网关通用请求 | 通用http request抽象 |
| 9 | yfcloud-mq-starter-rocketmq | 业务消息队列 | 业务项目建议使用rocketmq |
| 10 | yfcloud-mq-starter-kafka | 大数据消息队列 | 大数据建议使用kafka |
* 组件库仓库地址:https://gitee.com/yfclouds/yfcloud-repo/tree/1.0.0-dev/
* 温馨提示:基础产品研发自己积累的组件库,当前版本是1.0.0-dev
## 四、组件库范例 yfcloud-repo-example
### 1. 范例项目架构
* 服务端Server
* 客户端client
### 2. RPC请求规范
* RPC接口需要定义单独的url地址,安全控制保障仅内部微服务之间调用
### 3. 拦截器
* 支持通过Springboot拦截器获取请求header数据
### 4. 代码生成
* 支持多种模式生成代码:部分覆盖、全部覆盖、个性化覆盖,建议使用全部覆盖结合idea的版本管理来合并代码
## 五、补充内容
### 1. 范例项目配套课件材料
* [《技术框架2.0第五课:全场景代码生成》 --- 计划中](https://yifeng.yuque.com/docs/share/02aab0ff-f930-488c-9a6b-9d50d897f3eb)
* [《技术框架2.0第四课:消息队列》 --- 计划中](https://yifeng.yuque.com/docs/share/08a1fc6b-c078-4ec8-8cb1-f9c086f3f1e1)
* [《技术框架2.0第三课:分布式缓存》](https://yifeng.yuque.com/docs/share/923765a0-098d-46d0-b93f-f70efdd4849b)
* [《技术框架2.0第二课:多功能查询》](https://yifeng.yuque.com/docs/share/da0a231b-9f51-41a1-bfac-f1ce35d4f769)
* [《技术框架2.0第一课:起航》](https://yifeng.yuque.com/docs/share/5b7a675b-5c74-4ddb-8488-63d9e2891374)
* [《Java后台设计开发规范2.0版本》](https://yifeng.yuque.com/docs/share/ba88c063-45df-42dd-9846-a09f88b660b4)
* [《技术框架2.0-OpenTalk》](https://yifeng.yuque.com/docs/share/586a33ae-2ec7-492b-95f3-5b82eb45c4db)
* [《新技术框架汇报》](https://yifeng.yuque.com/docs/share/76a59d21-9418-47b8-b691-ec0a929b1451)
### 2. jar模式调整为war模式
#### 1. 在server模块的pom.xml调整打包模式
```xml
war
```
#### 2. 在server模块的pom.xml排除内置tomcat
```xml
com.yifeng.repo
yfcloud-micro-service-starter-server
org.springframework.boot
spring-boot-starter-tomcat
```
#### 3. 在server模块的pom.xml排除spring-boot-maven-plugin
```xml
org.springframework.boot
spring-boot-maven-plugin
${spring-boot-dependencies.version}
true
true
true
repackage
```
#### 4. 在server模块的pom.xml引入war打包插件
```xml
org.apache.maven.plugins
maven-war-plugin
3.2.2
```
#### 5. 在server模块的ApplicationStartUp重写启动方法
```java
@EnableMybatis
@SpringBootApplication
public class ApplicationStartUp extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(ApplicationStartUp.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(ApplicationStartUp.class);
}
}
```
#### 6. 如果启动发现没有打印日志的解决建议
```text
1. 在application.yml中配置的 logging.config: classpath:logback-spring.xml
2. 检查类方法:org.springframework.boot.context.logging.LoggingApplicationListener#initializeSystem
String logConfig = StringUtils.trimWhitespace(environment.getProperty(CONFIG_PROPERTY));
3. 断点跟踪检查logConfig的实际获取值,如果返回错误的值就表示没有获取到日志配置地址,也就是不能打印日志
正确:classpath:logback-spring.xml
错误:-Djava.util.logging.config.file="C:\Users\00115\AppData\Local\JetBrains\IntelliJIdea2020.1\tomcat\Unnamed_yfcloud-transport\conf\logging.properties"
4. 解决方案:启动参数加上 -Dlogging.config=classpath:logback-spring.xml
```
### 3. 仓库地址
* 发布库:[Release](http://nexus.pharmacyyf.com/repository/maven-releases/)
* 快照库:[Snapshot](http://nexus.pharmacyyf.com/repository/maven-snapshots/)
* 私服仓库地址
```xml
pharmacyyf-release
Pharmacyyf Nexus Release
http://nexus.pharmacyyf.com/repository/maven-releases/
pharmacyyf-snapshot
Pharmacyyf Nexus Snapshot
http://nexus.pharmacyyf.com/repository/maven-snapshots/
true
always
warn
```
* maven settings 配置
首先对源仓库(pharmacyyf-release、pharmacyyf-snapshot)配置访问参数,如下可供参考,
其次对代理以前的talkyun仓库(talkyun-release、talkyun-snapshot)、yifengx仓库(yifengx-release、yifengx-snapshot)配置访问参数。
```xml
pharmacyyf-release
******
******
pharmacyyf-snapshot
******
******
```
最后是调整仓库镜像,将https://repo1.maven.org/maven2替换为如下的配置
```xml
central
central
http://nexus.pharmacyyf.com/repository/Central_maven/
central
```