3.1 服务端配置文件
构建Spring Boot项目时,会在resource目录下自动生成一个空的application.yml 文件,Spring Boot项目启动时会自动加载application.yml文件。
我们可以在application.yml文件中定义Spring Boot项目的相关属性,当然,这些相关属性可以是系统属性、环境变量、命令参数等信息,也可以是自定义配置文件名称和位置。
3.2 前端配置文件
主要用于配置各个服务的路径信息,其中包括其他前端页面的访问路径,服务端各服务的访问信息以及单点登录服务的访问信息。
4 配置文件使用说明
4.1 服务端配置命名规范
application-dev.
yml:开发环境A
application-test. yml:测试环境B
application-uat.
yml:用户测试验收环境C
application-prod.yml:生产环境 D
4.2 服务端配置文件放置位置
源码中的每个项目下都会有一个src/main/resource文件夹,部分项目下会有src/test/resource文件夹,配置文件主要放在对应resource文件夹下。
src/test/resource 文件夹下的配置文件主要用作单元测试使用,src/main/resource文件夹下的配置文件会在编译时正式生效。
4.3 服务端各配置文件作用方式
配置文件可以基于同一个配置信息进行多次定义,并且通过指定生效文件的方式来找到最终以哪个文件的配置为主。
对于重复定义的配置信息的生效优先级为:
“各项目下的配置文件” < “base下的配置文件” < “assembly下的配置文件” < “部署包中的application-uat.yml”
4.4 前端配置文件放置位置
前端配置文件在前端源码(WEB项目)各个工程的public/sso.js文件中进行定义,编译之后,可以直接在部署路径下修改sso.js文件。
5 产品配置文件内容说明
5.1 前端配置文件配置说明
window.context = {
manage: 'http://localhost:8080/mvue', //管理端页面
front: 'http://localhost:8081/fvue', //前端页面
mobile: 'http://localhost:8082/mobilevue', //手机端页面
portal: 'http://localhost:8088', //portal服务访问地址
bpmRunTime: 'http://localhost:8088', // bpmRunTime服务访问地址
bpmModel: 'http://localhost:8088', // bpmModel服务访问地址
uc: 'http://localhost:8088', // uc服务访问地址
form: 'http://localhost:8088' // form服务访问地址
};
// 单点配置
window.ssoConfig = {
mode: "", // 空则不使用单点 支持的模式有 cas oauth basic
url: 'http://127.0.0.1:8093/oauth/authorize', // 单点登录服务路径
clientId: 'eip7',// oauth模式下需要提供
logout: 'http://127.0.0.1:8093/logout' // 日志输出路径
}
5.2 服务端部署常用配置
该部分配置主要在部署环境的application-uat.yml中进行定义,可以对开发常用配置和基础配置里面的内容重新进行覆盖式定义。
Ø 文件信息配置
spring:
profiles:
active: dev #配置生效的文件后缀
title: "@@project.name@@" #配置启动的项目名称
description: "@@project.description@@" #配置项目描述
version: "@@project.version@@" #配置项目版本
Ø mysql数据库链接配置
datasource:
dynamic:
datasource:
master: #表示在配置主数据库
username: root #数据库连接账号
password: root #数据库连接密码
driver-class-name: com.mysql.cj.jdbc.Driver #mysql数据库驱动
url: jdbc:mysql://IP:端口/数据库名称?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false&maxReconnects=10 #mysql数据库的连接信息,其中要将标绿部分改为数据库真实的IP,端口和数据库名
druid: #数据库连接池配置
validation-query: select 1 #mysql数据库校验
testWhileIdle: true #默认配置
testOnBorrow: true #默认配置
testOnReturn: true #默认配置
Ø oracle数据库链接配置
datasource:
dynamic:
datasource:
master: #表示在配置主数据库
username: root #数据库连接账号
password: root #数据库连接密码
driver-class-name: oracle.jdbc.OracleDriver #oracle数据库驱动
url: jdbc:oracle:thin:@IP:端口:服务名#配置IP,端口与服务名
druid:
validation-query: select 1 from dual #oracle数据库校验
testWhileIdle: true #默认配置
testOnBorrow: true #默认配置
testOnReturn: true #默认配置
Ø 服务端口配置
server: #设定服务端服务的端口
port: 8088
Ø Redis链接配置
redis:
database: 6 #redis的15个数据库随机选择一个(1-15),微服务部署时,各个配置文件都需要选择同一个数据库
host: 192.168.1.51 –redis部署服务器的IP
port: 6379 –redis端口,默认就是6379
password: –redis访问密码,可以不用填写
redis: #是否使用redis,true则使用,false则不使用
enable: true
Ø Mq链接配置
activemq:
broker-url: tcp://192.168.1.51:61616 #安装mq的服务器IP及MQ访问端口,默认就是61616
user:
password:
jms: #是否使用mq,true则使用,false则不使用
enable: true
Ø Eureka微服务注册中心配置
5.3 服务端开发常用配置
该部分配置主要在assembly\src\main\resources下的application-dev.yml中进行定义,主要是开发人员在开发环境中进行配置和调试使用。该文件可以对基础配置里面的内容重新进行覆盖式定义。该文件中的很多配置项会和“部署常用配置”中的内容重复定义,这里不做重复介绍。
5.4 服务端基础配置
该部分配置主要在E:\work\X7.2.2\trunk\base\src\main\resources\config下的application.yml中进行定义,主要用于定义基础的,不经常改动的配置信息。该文件中的配置信息会全面很多。
Ø Http配置
http:
encoding:
enabled: true
force: true
charset: UTF-8
messages:
encoding: UTF-8
servlet:
multipart:
maxFileSize: 1024MB
maxRequestSize: 1024MB
freemarker:
template-loader-path: classpath:/templates/ #模板加载路径 按需配置
charset: UTF-8
Ø redis基础配置
redis:
timeout: 2000
lettuce:
pool:
max-active: 8
max-idle: 8
min-idle: 0
Ø jms基础配置
jms:
pub-sub-domain: true
cache:
enabled: false
activemq:
in-memory: false
pool:
enabled: false
packages:
trust-all: true
trusted: com.hotent.activemq.model,com.hotent.base.jms,java.util,java.lang #信任所有的包
messages:
basename: i18n/messages
encoding: UTF-8
Ø 服务端端口基础配置
server:
port: 8088
address: 0.0.0.0
sessionTimeout: 30
contextPath: /
undertow:
io-threads: 2
worker-threads: 30
session:
timeout: 30
compression:
enabled: true
mime-types: "text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json"
min-response-size: 1024
Ø 是否启用队列,默认的队列名和订阅名
jms:
enable: true
queue:
name: eipQueue_tt
topic:
name: eipTopic_tt
Ø 指定可跨域的域名
cross:
allowOrigin:
Ø 配置打印SQL语句
logging:
config: classpath:config/logback-spring.xml
level:
com.hotent.uc.dao: debug
management:
Ø 忽略ldap的健康检查
health:
LDAP.enabled: false
add-application-context-header: false
endpoints:
web:
exposure:
include: health,info,cert
info:
app:
encoding: "@@project.build.sourceEncoding@@"
java:
source: "@@java.version@@"
target: "@@java.version@@"
banner:
charset: UTF-8
mybatis-plus:
configuration:
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
update-strategy: IGNORED # FieldStrategy
mybatis:
typeAliasesPackage: com.hotent.base.entity
mapperLocations: classpath*:mapper/*.xml
typeHandlersPackage: com.hotent.base.typehandle
Ø token生成配置
jwt:
header: Authorization
secret: mySecret
single: false # 单用户登录
expiration: 86400 # 单位秒
route:
authentication:
path: auth
refresh: refresh
Ø 系统中发送邮件的账号
mail:
host: smtp.qq.com
port: 25
ssl: false
nickName: "eip7管理员"
username: 1192668375@qq.com
password: bpzgyqhznjnnihje
Ø 系统配置
system:
# 系统ID生成种子
id:
# 数据中心ID,取值范围为0-31
datacenterId: 1
# 服务器ID,取值范围为0-31
workerId: 1
# 默认的附件上传目录,会被系统属性中配置覆盖
attachment:
type: folder
path: /home/eip/attachment
bpm:
engineName: eip7
# 多租户
saas:
# 是否开启多租户模式,注意:非租户模式和租户模式下数据有差异性,切换后可能导致数据异常
enable: true
# 忽略租户隔离的物理表名
ignoreTables:
Ø 附件在线预览
file:
file.dir: /home/eip/conver/
office.home: /opt/openoffice4
simText: txt,html,xml,java,properties,sql
media: mp3,mp4,flv,rmvb,wmv
converted.file.charset: utf-8
Ø 单点登录配置
sso:
enable: true
mode: jwt # jwt cas oauth
cas:
url: http://www.hotent.org:7080/cas #CAS服务地址
oauth:
url: http://192.168.1.211:8093 #oauth2服务地址
loginPath: /oauth/authorize
tokenPath: /oauth/token
checkPath: /oauth/check_token
clientId: eip7
secret: flossy
Ø 富文本控件上传文件的接口地址 portal
base.domain: http://127.0.0.1:8088
Ø 分布式事务
seata:
enabled: false
application-id: ${spring.application.name}
tx-service-group: ${spring.application.name}
enable-auto-data-source-proxy: true
use-jdk-proxy: false
excludes-for-auto-proxying: firstClassNameForExclude,secondClassNameForExclude
client:
rm:
async-commit-buffer-limit: 1000
report-retry-count: 5
table-meta-check-enable: false
report-success-enable: false
saga-branch-register-enable: false
lock:
retry-interval: 10
retry-times: 30
retry-policy-branch-rollback-on-conflict: true
tm:
degrade-check: false
degrade-check-period: 2000
degrade-check-allow-times: 10
commit-retry-count: 5
rollback-retry-count: 5
undo:
data-validation: true
log-serialization: jackson
log-table: undo_log
only-care-update-columns: true
log:
exceptionRate: 100
service:
vgroup-mapping:
portal-eureka: SEATA-SERVER
uc-eureka: SEATA-SERVER
form-eureka: SEATA-SERVER
bpm-model-eureka: SEATA-SERVER
bpm-runtime-eureka: SEATA-SERVER
grouplist:
default: 192.168.1.21:8091
enable-degrade: false
disable-global-transaction: false
transport:
shutdown:
wait: 3
thread-factory:
boss-thread-prefix: NettyBoss
worker-thread-prefix: NettyServerNIOWorker
server-executor-thread-prefix: NettyServerBizHandler
share-boss-worker: false
client-selector-thread-prefix: NettyClientSelector
client-selector-thread-size: 1
client-worker-thread-prefix: NettyClientWorkerThread
worker-thread-size: default
boss-thread-size: 1
type: TCP
server: NIO
heartbeat: true
serialization: seata
compressor: none
enable-client-batch-send-request: true
config:
type: file
consul:
server-addr: 127.0.0.1:8500
apollo:
apollo-meta: http://192.168.1.204:8801
app-id: seata-server
namespace: application
etcd3:
server-addr: http://localhost:2379
nacos:
namespace:
serverAddr: 127.0.0.1:8848
group: SEATA_GROUP
userName: ""
password: ""
zk:
server-addr: 127.0.0.1:2181
session-timeout: 6000
connect-timeout: 2000
username: ""
password: ""
registry:
type: eureka
consul:
server-addr: 127.0.0.1:8500
etcd3:
serverAddr: http://localhost:2379
eureka:
weight: 1
service-url: ${eureka.client.service-url.defaultZone}
nacos:
application: seata-server
server-addr: 127.0.0.1:8848
namespace:
userName: ""
password: ""
redis:
server-addr: localhost:6379
db: 0
password:
timeout: 0
sofa:
server-addr: 127.0.0.1:9603
region: DEFAULT_ZONE
datacenter: DefaultDataCenter
group: SEATA_GROUP
addressWaitTime: 3000
application: default
zk:
server-addr: 127.0.0.1:2181
session-timeout: 6000
connect-timeout: 2000
username: ""
password: ""
Ø 注册中心
eureka:
client:
healthcheck:
enabled: true
service-url:
defaultZone: http://127.0.0.1:8761/eureka/
instance:
lease-expiration-duration-in-seconds: 30
lease-renewal-interval-in-seconds: 10
# 注册到eureka时使用ip地址
prefer-ip-address: true
# eureka会自动识别每个微服务的ip地址,如果需要指定ip则配置该属性
# ip-address: 127.0.0.1
instance-id: ${spring.cloud.client.ip-address}:${server.port}
Ø feign配置
feign:
hystrix:
enabled: true
httpclient:
enabled: true
client:
config:
default:
connectTimeout: 50000
readTimeout: 50000
loggerLevel: full
Ø 断路器配置
hystrix:
metrics:
enabled: true
command:
default:
execution:
isolation:
strategy: SEMAPHORE # THREAD SEMAPHORE
semaphore:
maxConcurrentRequests: 200 # 默认情况下下面两个值都是10,也就是超过10个的并发会直接进入fallback方法,不会去真正请求
thread:
timeoutInMilliseconds: 50000 #缺省为1000
fallback:
isolation:
semaphore:
maxConcurrentRequests: 200 # 默认情况下下面两个值都是10,也就是超过10个的并发会直接进入fallback方法,不会去真正请求
Ø 负载均衡配置
ribbon:
eureka:
enabled: true
Ø uniapp集成的个推
unipush:
appId: ShVpFTXPhu9SIHivD2Kon6
appKey: YJWwctAp916G9uoWfPwh2A
appSecret: uqgpgsFSLx5RgUG5nvlpZ4
masterSecret: MJJ8lWVDAX77cr9kLUuBY9
host: http://api.getui.com/apiex.htm
xxl:
job:
enabled: false #如果使用xxl则不使用quartz
accessToken: ''
admin:
addresses: http://192.168.1.100:8120/xxl-job-admin
executor:
address: ''
appname: ${spring.application.name}
ip: ''
logpath: /data/applogs/xxl-job/jobhandler
logretentiondays: 30
port: 9999