安睿智达微服务开发平台采用J2EE 技术体系,基于Spring Cloud微服务开发套件。平台设计灵活可扩展、可移植、可应对高并发需求。同时兼顾本地化、云化部署,支持SaaS模式应用。平台可以很容易的将业务对象作为基本单元进行纵向拆分,以交互层次作为标准进行横向拆分,从而形成多应用交互的微应用架构体系,有效的实现应用的拆分,实现敏捷开发和部署,平台通过使用Maven来管理模块依赖,并根据系统架构设计,以业务需求来将代码分模块管理,所有公共组件全部发布公司Nexus服务器,从而实现业务系统整体的模块化开发。另外模块化的拆分按照“高内聚、低耦合”的原则,服务组件之间有清晰的边界,易于拓展和按需选配部署,可根据需要选择要应用的模块、服务,也可自行开发增加模块、服务。
部署环境说明
| 工具 | 版本 | 备注 |
|---|---|---|
| JDK | 1.8 | 必须 |
| MySQL | 5.7.31 | 必须 Best between 5.7.31 to 8.x |
| Redis | 3.2 + | 必须 |
| RabbitMQ | 3.8.9 | 必须 |
| Nginx | 1.9.x | |
| Nacos | 1.4.x | 必须 |
安装MySQL
数据库版本Best between 5.7.31 to 8.x
https://www.runoob.com/mysql/mysql-install.html
安装redis
https://www.runoob.com/redis/redis-install.html
安装RabbitMQ
https://www.rabbitmq.com/download.html
安装Nginx
http://nginx.org/en/linux_packages.html
Nacos安装
https://nacos.io/zh-cn/docs/quick-start.html
将微服务配置依次导入

中间件启动顺序
1. MySQL
2. RabbitMQ
3. Redis
4. Nginx
5. Nacos
微服务
认证服务
ivy-auth 对 Spring Security OAtuh2 的资源服务器配置进行了封装。
其他微服务引入依赖既可实现安全认证服务
<!--安全模块-->
<dependency>
<groupId>com.ivystar</groupId>
<artifactId>ivy-common-security</artifactId>
<version>2.10.3</version>
</dependency>
微服务配置
security:
oauth2:
client:
client-id: ENC(yaJ7406tphjC1fXPQNwtbw==)
client-secret: ENC(yaJ7406tphjC1fXPQNwtbw==)
scope: server
# 数据源
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: user
password: pass
url: jdbc:mysql://192.168.0.3:3306/ivy-intelligent-base?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
freemarker:
allow-request-override: false
allow-session-override: false
cache: true
charset: UTF-8
check-template-location: true
content-type: text/html
enabled: true
expose-request-attributes: false
expose-session-attributes: false
expose-spring-macro-helpers: true
prefer-file-system-access: true
suffix: .ftl
template-loader-path: classpath:/templates/
其他微服务 main 方法开启 @EnableIvyResourceServer
@EnableIvyResourceServer
@EnableIvyFeignClients
@SpringCloudApplication
public class IvyAdminApplication {
public static void main(String[] args) {
SpringApplication.run(IvyAdminApplication.class, args);
}
}
基础管理服务
ivy-system-service 提供用户、角色、组织架构等基础服务。
微服务配置
security:
oauth2:
client:
client-id: ENC(yaJ7406tphjC1fXPQNwtbw==)
client-secret: ENC(yaJ7406tphjC1fXPQNwtbw==)
scope: server
# 数据源
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: user
password: pass
url: jdbc:mysql://192.168.0.3:3306/ivy-intelligent-base?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
freemarker:
allow-request-override: false
allow-session-override: false
cache: true
charset: UTF-8
check-template-location: true
content-type: text/html
enabled: true
expose-request-attributes: false
expose-session-attributes: false
expose-spring-macro-helpers: true
prefer-file-system-access: true
suffix: .ftl
template-loader-path: classpath:/templates/
对象存储服务
ivy-oss-service 对象存储服务支撑云端和本地磁盘存储。
微服务配置
security:
oauth2:
client:
client-id: ENC(fpm2KfuU/QaK7Z07395cng==)
client-secret: ENC(7nypIHnykcoRSiV9Hj22+Q==)
scope: server
local:
#本地文件上传路径 /root/fileupload
upload-path: /root/fileupload
#本地文件预览地址
view-path: http://192.168.0.3:82/view
storage:
environment:
model:
#是否云端存储
cloud-storage: false
#是否本地存储
local-storage: true
oss:
huawei:
obs:
config:
metadata:
buckets:
- ivy-security-bucket
enabled: true #开启 obs
end-point: obs.cn-southwest-2.myhuaweicloud.com #西南-贵阳一
custom-url: oss.ivy.com #自定义域名
ak: accessKey #永久accessKey
sk: secretKey #永久secretKey
socket-timeout: 300000 #socket 超时 默认300s
connection-timeout: 10000 #connection 超时 默认10s
bucket-loc: cn-southwest-2 # 默认
expire-seconds: 86400 #私有情况下上传成功后URL有效期,1天,单位s秒
#以下是使用iam账户操作
iam-end-point: https://iam.cn-north-4.myhuaweicloud.com #临时AK、SK 生成 参数 华为iam
user-name: user #iam用户名
pass-word: pass #iam密码
domain-name: user #iam账户名字
duration-seconds: 82800 #临时token失效时间
网关服务
微服务配置
security:
oauth2:
client:
client-id: ENC(yaJ7406tphjC1fXPQNwtbw==)
client-secret: ENC(yaJ7406tphjC1fXPQNwtbw==)
scope: server
spring:
cloud:
gateway:
locator:
enabled: true
routes:
# 认证中心
- id: ivy-auth
uri: lb://ivy-auth
predicates:
- Path=/auth/**
filters:
# 验证码处理
- ValidateCodeGatewayFilter
# 前端密码解密
- PasswordDecoderFilter
#system 模块
- id: ivy-system-service
uri: lb://ivy-system-service
predicates:
- Path=/admin/**
filters:
# 限流配置
- name: RequestRateLimiter
args:
key-resolver: '#{@remoteAddrKeyResolver}'
redis-rate-limiter.replenishRate: 100
redis-rate-limiter.burstCapacity: 200
#management 模块
- id: ivy-manage-service
uri: lb://ivy-manage-service
predicates:
- Path=/manage/**
filters:
# 限流配置
- name: RequestRateLimiter
args:
key-resolver: '#{@remoteAddrKeyResolver}'
redis-rate-limiter.replenishRate: 100
redis-rate-limiter.burstCapacity: 200
#system 模块
- id: ivy-system-service
uri: lb://ivy-system-service
predicates:
- Path=/admin/**
filters:
# 限流配置
- name: RequestRateLimiter
args:
key-resolver: '#{@remoteAddrKeyResolver}'
redis-rate-limiter.replenishRate: 100
redis-rate-limiter.burstCapacity: 200
#management 模块
- id: ivy-manage-service
uri: lb://ivy-manage-service
predicates:
- Path=/manage/**
filters:
# 限流配置
- name: RequestRateLimiter
args:
key-resolver: '#{@remoteAddrKeyResolver}'
redis-rate-limiter.replenishRate: 100
redis-rate-limiter.burstCapacity: 200
#device 模块
- id: etm-device
uri: lb://etm-device
predicates:
- Path=/device/**
filters:
# 限流配置
- name: RequestRateLimiter
args:
key-resolver: '#{@remoteAddrKeyResolver}'
redis-rate-limiter.replenishRate: 100
redis-rate-limiter.burstCapacity: 200
#inspection 模块
- id: etm-inspection
uri: lb://etm-inspection
predicates:
- Path=/inspection/**
# OSS
- id: ivy-oss-service
uri: lb://ivy-oss-service
predicates:
- Path=/oss/**
# PHM接口iot
- id: ivy-phm-iot
uri: lb://ivy-phm-iot
predicates:
- Path=/ivy-phm-iot/**
# PHM接口view
- id: ivy-phm-view
uri: lb://ivy-phm-view
predicates:
- Path=/ivy-phm-view/**
# license接口
- id: ivy-license-service
uri: lb://ivy-license-service
predicates:
- Path=/ls/**
# iot(dcs)
- id: ivy-iot-service
uri: lb://ivy-iot-service
predicates:
- Path=/iot/**
gateway:
validateCodeEnabled: false
encode-key: 'thanks, ivy cloud'
ignore-clients:
- test
swagger:
ignore-providers:
- ivy-auth
- ivy-code-generator
Excel 导入导出
EasyExcel
EasyExcel是一个基于Java的简单、省内存的读写Excel的开源项目。在尽可能节约内存的情况下支持读写百M的Excel。Java解析、生成Excel比较有名的框架有Apache poi、jxl。但他们都存在一个严重的问题就是非常的耗内存,poi有一套SAX模式的API可以一定程度的解决一些内存溢出的问题,但POI还是有一些缺陷,比如07版Excel解压缩以及解压后存储都是在内存中完成的,内存消耗依然很大。easyexcel重写了poi对07版Excel的解析,能够原本一个3M的excel用POI sax依然需要100M左右内存降低到几M,并且再大的excel不会出现内存溢出,03版依赖POI的sax模式。在上层做了模型转换的封装,让使用者更加简单方便
spring boot stater依赖
- 方便在 web 环境下使用
easyexcel,已上传至 公司maven 仓库
<dependency>
<groupId>com.ivystar</groupId>
<artifactId>ivy-common-excel</artifactId>
<version>2.10.1</version>
</dependency>
微服务启动顺序
1. 基础微服务
2. 认证微服务
3. 对象存储微服务
4. 网关微服务
5. 服务监控
前端打包说明
安装node & npm
官网下载node安装包
https://nodejs.org/zh-cn/
参考资料
https://spring.io/projects/spring-cloud/
https://www.springcloud.cc/
https://baomidou.com/
https://www.runoob.com/w3cnote/fastjson-intro.html
