# 配置文件

jweb-boot 通过 Jboot配置文件进行配置。

# Jboot配置 (opens new window)

在 Jboot 应用中,可以通过几下几种方式给 Jboot 应用进行配置。

  1. jboot.properties 配置文件
  2. jboot-xxx.properties 配置文件
  3. 环境变量
  4. Jvm 系统属性
  5. 启动参数
  6. 分布式配置中心(目前支持 ApolloNacos

注意

  1. 如果同一个属性被多处配置,那么 Jboot 读取配置的优先顺序是:
    分布式配置中心 > 启动参数 > Jvm 系统属性 > 环境变量 > jboot-xxx.properties > jboot.properties

  2. jboot-xxx.properties 的含义是:
    当配置 jboot.app.mode=dev 时,默认去读取 jboot-dev.properties
    当配置 jboot.app.mode=product 时,默认去读取 jboot-product.properties
    jboot-xxx.properties 这个文件并不是必须的,但当该配置文件存在时,其读取优先级大于 jboot.properties

# 读取配置

这里使用Jweb.configValue(key),原Jboot读取为 Jboot.configValue(key),Jweb继承Jboot并增强功能。

String host = Jweb.configValue("undertow.host")
String port = Jweb.configValue("undertow.port")
1
2

# 注入配置

public class AopController extends JwebController {

    @ConfigValue("undertow.host")
    private String host;

    @ConfigValue("undertow.port")
    private int port;

    public void index(){
        renderText("host:" + host +"   port:" + port);
    }
}
1
2
3
4
5
6
7
8
9
10
11
12

# 动态配置

在 Jboot 的所有配置中,我们可以通过 ${key} 来指定替换为 value

例外

如果配置整合了第三方配置文件,由于加载时机不同,可能不支持动态配置.
比如合并sentinel.properties到jboot.properties就不支持

示例1:

key1 = value1
key2 = ${key1}/abc
1
2

那么读取到的 key2 的值为 value1/abc

示例2:

key1 = value1
key2 = ${key1}/abc
key3 = abc/${key2}/xyz
1
2
3

那么,key2 的值为 value1/abckey3 的值为 abc/value1/abc/xyz

示例2:

key1 = value1
key2 = ${otherkey}/abc
1
2

那么,因为系统中找不到 otherkey 的值,key2 的值为 /abc,如果我们在系统中,通过 java -jar xxx.jar --otherkey=othervalue, 那么, key2 的值为 othervalue/abc

# 配置实体类

很多时候,某个功能或组件可能需要一堆的配置,而不是一个配置,无论是手动编码读取 或者 是通过注入,就可以让我们的项目产生重复的代码。
Jboot 提供了配置实体类功能,该功能自动把配置信息 映射 给一个 JavaBean 实体类,方便我们 批量 读取配置信息。

例如: 某个组件叫 component1 ,我们可以创建一个叫 Component1Config 的实体类,定义好其属性,如下代码 :

@ConfigModel(prefix="component1")
public class Component1Config{
    private String host;
    private int port;
    private String accout;
    private String password;
    private long timeout;
    private String [] hobbys;
    private EmailConfig email;
    // 下方应该还有 getter setter, 略
}
1
2
3
4
5
6
7
8
9
10
11

jboot.properties文件中如下配置:

component1.hosts=********
component1.port=********
component1.accout=********
component1.password=********
component1.timeout=********
component1.hobbys=********,***,****,**
component1.email.server=********
component1.email.port=********
component1.email.password=********
1
2
3
4
5
6
7
8
9

这样,我们就可以通过如下代码读 Component1Config 信息。

Component1Config config = Jweb.config(Component1Config.class);
1

不难看出:@ConfigModel(prefix="component1") 注解的含义是就是标识 配置实体类 从配置文件中获取指定前缀(component1)的配置值。

进阶

除了自动解析基本的数据类型外,还支持

  1. 嵌套配置实体类类型。 比如上面配置中的EmailConfig类型。
  2. String[]List<String>Set<String>类型。不同值用逗号隔开,如:v1,v2,v3,v4。
  3. Map<String,String>类型。不同键值用逗号隔开,如:k1:v1,k2:v2,k3:v3。
  4. Class类型。自动将配置的类名转为Class对象。

# 其它配置方式

  1. 如何设置启动参数 ?

答:在 fatjar 模式下,可以通过添加 --(两个中划线) 来指定配置,例如:java -jar --undertow.port=8080 --undertow.host=0.0.0.0

  1. 如何设置 Jvm 系统属性 ?

答:和启动参数一样,只需要把 -- 换成 -D,例如: java -jar -Dundertow.port=8080 -Dundertow.host=0.0.0.0

  1. 如何设置系统环境变量 ?

答:在 Docker 下,启动 Docker 容器的时候,只需要添加 -e 参数即可,例如: docker run -e undertow.port=8080 xxxx Linux、Window、Mac 搜索引擎自行搜索关键字: 环境变量配置

注意

在设置的系统环境变量的key、value中,例如:jboot.app.mode = dev 可以修改为 JBOOT_APP_MODE = dev ,其他同理把全部小写 修改为大写,符号点(.)修改为下划线(_)。`

# 配置参数大全

jboot配置大全参考:

undertow.devMode=true # 设置undertow为开发模式
undertow.port=80 #undertow 的端口号,默认 8080,配置 * 为随机端口
undertow.host=0.0.0.0 #默认为localhost
undertow.resourcePath = src/main/webapp, classpath:static
undertow.ioThreads=
undertow.workerThreads=
undertow.gzip.enable=true # gzip 压缩开关
undertow.gzip.level=-1 # 配置压缩级别,默认值 -1。 可配置 1 到 9。 1 拥有最快压缩速度,9 拥有最高压缩率
undertow.gzip.minLength=1024 # 触发压缩的最小内容长度
undertow.session.timeout=1800 # session 过期时间,注意单位是秒
undertow.session.hotSwap=true # 支持 session 热加载,避免依赖于 session 的登录型项目反复登录,默认值为 true。仅用于 devMode,生产环境无影响
undertow.ssl.enable=false # 是否开启 ssl
undertow.ssl.port=443 # ssl 监听端口号,部署环境设置为 443
undertow.ssl.keyStoreType=PKCS12 # 密钥库类型,建议使用 PKCS12
undertow.ssl.keyStore=demo.pfx # 密钥库文件
undertow.ssl.keyStorePassword=123456 # 密钥库密码
undertow.ssl.keyAlias=demo # 别名配置,一般不使用
undertow.http2.enable=true # ssl 开启时,是否开启 http2
undertow.http.toHttps=false # ssl 开启时,http 请求是否重定向到 https
undertow.http.toHttpsStatusCode=302 # ssl 开启时,http 请求跳转到 https 使用的状态码,默认值 302
undertow.http.disable=false # ssl 开启时,是否关闭 http

#-------- jweb-boot 附加undertow参数 start--------
# undertow welcome page , 类似tomcat 的 welcome file list 配置
undertow.welcomePages=index.html,index.htm,index
# undertow error page 配置 , 如:404:/404.html,500:/error/500.html, 默认为空
undertow.errorPages=
#-------- jweb-boot 附加undertow参数 end--------

jboot.app.mode
jboot.app.bannerEnable
jboot.app.bannerFile
jboot.app.jfinalConfig

jboot.web.webSocketEndpoint
jboot.web.cookieEncryptKey

jboot.web.session.cookieName
jboot.web.session.cookieDomain
jboot.web.session.cookieContextPath
jboot.web.session.maxInactiveInterval
jboot.web.session.cookieMaxAge
jboot.web.session.cacheName
jboot.web.session.cacheType

jboot.web.jwt.httpHeaderName
jboot.web.jwt.secret
jboot.web.jwt.validityPeriod

jboot.web.cdn.enable
jboot.web.cdn.domain


jboot.datasource.name
jboot.datasource.type
jboot.datasource.url
jboot.datasource.user
jboot.datasource.password
jboot.datasource.driverClassName = com.mysql.jdbc.Driver
jboot.datasource.connectionInitSql
jboot.datasource.poolName
jboot.datasource.cachePrepStmts = true
jboot.datasource.prepStmtCacheSize = 500
jboot.datasource.prepStmtCacheSqlLimit = 2048
jboot.datasource.maximumPoolSize = 10
jboot.datasource.maxLifetime
jboot.datasource.idleTimeout
jboot.datasource.minimumIdle = 0
jboot.datasource.sqlTemplatePath
jboot.datasource.sqlTemplate
jboot.datasource.factory
jboot.datasource.shardingConfigYaml
jboot.datasource.dbProFactory
jboot.datasource.containerFactory
jboot.datasource.transactionLevel
jboot.datasource.table //此数据源包含哪些表
jboot.datasource.exTable //该数据源排除哪些表
jboot.datasource.dialectClass
jboot.datasource.activeRecordPluginClass
jboot.datasource.needAddMapping = true //是否需要添加到映射,当不添加映射的时候,只能通过 model.use("xxx").save()这种方式去调用该数据源



jboot.mq.type
jboot.mq.channel
jboot.mq.serializer
jboot.mq.syncRecevieMessageChannel

jboot.mq.redis.host
jboot.mq.redis.port
jboot.mq.redis.password
jboot.mq.redis.database
jboot.mq.redis.timeout
jboot.mq.redis.clientName
jboot.mq.redis.testOnCreate
jboot.mq.redis.testOnBorrow
jboot.mq.redis.testOnReturn
jboot.mq.redis.testWhileIdle
jboot.mq.redis.minEvictableIdleTimeMillis
jboot.mq.redis.timeBetweenEvictionRunsMillis
jboot.mq.redis.numTestsPerEvictionRun
jboot.mq.redis.maxAttempts
jboot.mq.redis.maxTotal
jboot.mq.redis.maxIdle
jboot.mq.redis.maxWaitMillis
jboot.mq.redis.serializer
jboot.mq.redis.type

jboot.mq.rabbitmq.username
jboot.mq.rabbitmq.password
jboot.mq.rabbitmq.host
jboot.mq.rabbitmq.port
jboot.mq.rabbitmq.virtualHost

jboot.mq.qpid.host
jboot.mq.qpid.username
jboot.mq.qpid.password
jboot.mq.qpid.virtualHost

jboot.mq.aliyun.accessKey
jboot.mq.aliyun.secretKey
jboot.mq.aliyun.addr
jboot.mq.aliyun.producerId
jboot.mq.aliyun.sendMsgTimeoutMillis

jboot.mq.zbus.queue
jboot.mq.zbus.broker

jboot.cache.type
jboot.cache.ehcache.configFileName
jboot.cache.redis.host
jboot.cache.redis.port
jboot.cache.redis.password
jboot.cache.redis.database
jboot.cache.redis.timeout
jboot.cache.redis.clientName
jboot.cache.redis.testOnCreate
jboot.cache.redis.testOnBorrow
jboot.cache.redis.testOnReturn
jboot.cache.redis.testWhileIdle
jboot.cache.redis.minEvictableIdleTimeMillis
jboot.cache.redis.timeBetweenEvictionRunsMillis
jboot.cache.redis.numTestsPerEvictionRun
jboot.cache.redis.maxAttempts
jboot.cache.redis.maxTotal
jboot.cache.redis.maxIdle
jboot.cache.redis.maxWaitMillis
jboot.cache.redis.serializer
jboot.cache.redis.type

jboot.schedule.cron4jFile
jboot.schedule.poolSize

jboot.model.scan
jboot.model.columnCreated
jboot.model.columnModified
jboot.model.idCacheEnable
jboot.model.idCacheType
jboot.model.idCacheTime

jboot.metric.url
jboot.metric.reporter
jboot.metric.reporter.cvr.path
jboot.metric.reporter.graphite.host
jboot.metric.reporter.graphite.port
jboot.metric.reporter.graphite.prefixedWith

jboot.wechat.debug
jboot.wechat.appId
jboot.wechat.appSecret
jboot.wechat.token
jboot.wechat.partner
jboot.wechat.paternerKey
jboot.wechat.cert

jboot.shiro.loginUrl
jboot.shiro.successUrl
jboot.shiro.unauthorizedUrl
jboot.shiro.ini
jboot.shiro.urlMapping
jboot.shiro.invokeListener

jboot.serializer.type

jboot.swagger.path
jboot.swagger.title
jboot.swagger.description
jboot.swagger.version
jboot.swagger.termsOfService
jboot.swagger.host
jboot.swagger.contactName
jboot.swagger.contactEmail
jboot.swagger.contactUrl
jboot.swagger.licenseName
jboot.swagger.licenseUrl

jboot.http.type

jboot.redis.host
jboot.redis.port
jboot.redis.password
jboot.redis.database
jboot.redis.timeout
jboot.redis.clientName
jboot.redis.testOnCreate
jboot.redis.testOnBorrow
jboot.redis.testOnReturn
jboot.redis.testWhileIdle
jboot.redis.minEvictableIdleTimeMillis
jboot.redis.timeBetweenEvictionRunsMillis
jboot.redis.numTestsPerEvictionRun
jboot.redis.maxAttempts
jboot.redis.maxTotal
jboot.redis.maxIdle
jboot.redis.maxWaitMillis
jboot.redis.serializer
jboot.redis.type


jboot.limit.enable
jboot.limit.rule
jboot.limit.fallbackProcesser
jboot.limit.defaultHttpCode
jboot.limit.defaultAjaxContent
jboot.limit.defaultHtmlView
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225

jweb配置大全参考:

#
# Copyright (c) 2020-2021 imlzw@vip.qq.com jweb.cc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#服务名配置
jweb.serviceName=demo


#-------- jweb-boot 附加undertow参数 start--------
# undertow welcome page , 类似tomcat 的 welcome file list 配置
undertow.welcomePages=index.html,index.htm,index
# undertow error page 配置 , 如:404:/404.html,500:/error/500.html, 默认为空
undertow.errorPages=
#-------- jweb-boot 附加undertow参数 end--------

#--------undertow 配置 start--------
# 热部署支持:
#   true:支持热部署,目前不完善,会丢失内存对象信息,建议false。
#   false:不支持热部署,但还是可以通过debug实现局部代码热加载。
undertow.devMode=false 
undertow.port=80
#配置host为通用的地址,默认为localhost, 如未配置,在启用服务发现时,会造成nacos无法主动探测到该服务而导致实例不健康的问题
undertow.host=0.0.0.0 
#配置webapp资源目录,默认为 src/main/webapp,webapp,classpath:webapp
#undertow.resourcePath=src/main/webapp
#undertow.hotSwapClassPrefix=org.apache.shiro.,cn.imlzw.,com.ndasec.,cc.jweb.
#--------undertow 配置 end--------






#--------jboot 杂项配置区 start--------
#应用模式设置: dev:开发模式,product:生产模式
jboot.app.mode=dev 
jboot.app.jfinalConfig = cc.jweb.boot.core.JwebCoreConfig
# json配置
jboot.json.camelCaseJsonStyleEnable=false
jboot.json.skipNullValueField=true
jboot.json.timestampPattern=yyyy-MM-dd HH:mm:ss
#websocket配置,多个 endpoint 用英文逗号(,) 隔开。
#jboot.web.webSocketEndpoint=com.ndasec.jweb.web.websocket.controller.WebSocketController
#--------jboot 杂项配置区 end--------






#--------jboot 数据库配置 start--------
jboot.datasource.type=mysql
jboot.datasource.url=jdbc:mysql://127.0.0.1:3306/web_base?characterEncoding=utf8&useSSL=true
jboot.datasource.user=root
jboot.datasource.password=root
#--------jboot 数据库配置 end--------


#--------jboot jwt配置 start--------
#配置JWT的密钥,当使用@EnableJwt时,必须配置,否则 jboot 会给出警告,密钥用base64编码
jboot.web.jwt.secret=MTIz
#--------jboot jwt配置 end--------




#--------jweb 安全模块配置 start--------
# 安全模块总开关,默认false
jweb.security.enable=true
# session超时时长(秒),默认30*60秒,即30分钟
jweb.security.sessionTimeout=10
# session类型:DEFAULT:http session,JWT:json web token session。{className}:自定义session实现类名
jweb.security.sessionType=JWT
# 可以直接写实现类
# jweb.security.sessionType=cc.jweb.boot.security.session.impl.JwebHttpSession

# jwt token 生成密钥,base64编码的,必填
jweb.security.jwt.secret=MTIz
# jwt token 存储keyName,默认为jwt
jweb.security.jwt.storeKey=jwtt
# jwt token 存储位置,可选:HEADER,COOKIE, 默认为cookie
jweb.security.jwt.storePosition=COOKIE


# jweb 登录模块配置 start--------
# 是否启用,默认true
jweb.security.authc.enable=true
# 配置未认证时,自动跳转登录地址,该地址不会被安全框架拦截。(注:一般也是登录表单提交的地址)。
jweb.security.authc.loginUrl=/login
# 需要认证登录的地址列表,多个地址用,隔开,采用AntPathMatch路径匹配规则
# Apache Ant样式的路径有三种通配符匹配方法。
#
#    ‘?’  匹配任何单字符
#    ‘*’  匹配0或者任意数量的字符
#    ‘**’ 匹配0或者更多的目录
#    /app/*.x      匹配(Matches)所有在app路径下的.x文件
#    /app/p?ttern  匹配(Matches) /app/pattern 和 /app/pXttern,但是不包括/app/pttern
#    /**/example   匹配(Matches) /app/example, /app/foo/example, 和 /example
#    /app/**/dir/file.  匹配(Matches) /app/dir/file.jsp, /app/foo/dir/file.html, /app/foo/bar/dir/file.pdf
#    /**/*.jsp     匹配(Matches)任何的.jsp 文件
jweb.security.authc.filtePaths=/**
# 排除不需要认证的地址列表,多个地址用隔开,采用AntPathMatch路径匹配规则
jweb.security.authc.excludePaths=/assets/**,/vcode,/401,/403,/file/**,/portal/**
# jweb 登录模块配置 end--------

# jweb 权限鉴权模块配置 start--------
# 是否启用,默认true
jweb.security.perms.enable=true
jweb.security.perms.failureUrl=/403
# 权限管理器(单例),管理权限校验接口,默认: JwebNonePermsManager,权限判定永远返回false,需要重写
# jweb.security.perms.manager=cc.jweb.boot.security.session.perms.JwebNonePermsManager

# jweb 登录模块配置 end--------

#--------jweb 安全模块配置 end--------





#--------jboot shiro 配置区 start--------
# shiro配置文件,一旦配置如下参数,即启用shiro功能
#jboot.shiro.ini=shiro.ini
# shiro过滤器路径映射
#jboot.shiro.urlMapping=/*
#--------jboot shiro 配置区 end--------






#--------jboot RPC配置 start--------
#RPC类型:dubbo...?
jboot.rpc.type = dubbo
#dubbo 的通信协议配置
jboot.rpc.dubbo.registry.address = nacos://127.0.0.1:8848
jboot.rpc.dubbo.protocol.name = dubbo
jboot.rpc.dubbo.protocol.port = 0
#--------jboot RPC配置 end--------






#--------jboot nacos 分布式配置中心 start--------
jboot.config.nacos.enable = true
jboot.config.nacos.serverAddr = 127.0.0.1:8848
jboot.config.nacos.dataId = user
jboot.config.nacos.group = dev
#--------jboot nacos 分布式配置中心 end--------






#--------jweb 服务发现配置 start--------
#服务发现开启
jweb.discovery.enable=false
#服务名称,服务关键字,后继调用服务dns名(必填)
jweb.discovery.serviceName=${jweb.serviceName}
#Nacos注册中心地址
jweb.discovery.registerAddress=http://192.168.2.202:8848
#命名空间,默认值:public(可选)
#jweb.discovery.namespace=public
#分组名称,默认值:DEFAULT_GROUP(可选)
#jweb.discovery.groupName=dev
#所属集群名称配置,默认值:DEFAULT(可选)
#jweb.discovery.clusterName=TEST
#是否为临时节点实例,默认:true。 true: 临时节点实现;false:为持久化实例;(可选)
#若为临时节点实例,客户端会主动产生上报心跳,来维护节点健康状况
#若为持久化实例,nacos服务器会主动检测服务健康状况,根据集群配置的检测类型:TCP,HTTP,NONE 来检测
jweb.discovery.ephemeral=false
#优先使用的注册的ip段。在一台服务器有多个网卡ip时,优先使用以下ip段(可选)
jweb.discovery.preferredNetworks=192.168.2,10.0
#忽略指定关键字的网卡。在一台服务器有多个网卡ip时,忽略包含以下关键字的网卡名(统一转小写)(可选)
#jweb.discovery.ignoredInterfaces=virtual,docker0,veth,hyper-v,vmware,vmnet,tap,docker,flannel,cni
#--------jweb 服务发现配置 end--------






#--------jweb 网关路由配置 start--------
# 需要配合配置 ---jweb 服务发现配置---
# 熔断限流支持需要配置 ---jweb 熔断限流sentinel配置---
# path 匹配示例
jweb.gateway.adai.enable = true
jweb.gateway.adai.name = jweb-adai
jweb.gateway.adai.uri = http://192.168.2.202:80
# 是否开启uri健康检查,默认false
jweb.gateway.adai.uriHealthCheckEnable = false
# 健康检查访问路径: {uri} + {checkPath}, 默认为 空, 返回200表示健康,每10s检查一次 
jweb.gateway.adai.uriHealthCheckPath = /your-health-check-path
jweb.gateway.adai.pathStartsWith = /adai/
# 路径重写,格式:【正则匹配】,【替换字符】。
# 目前简单使用java的,String.replaceAll来替换重写
jweb.gateway.adai.pathRewrite = /adai/,/
# 上下文路径配置
# 该配置将以Header值的形式传递给被代理的目标,
# 具体返回的html页面中的引用资源路径,需要开发者自动添加contextPath前缀,以适应网关再次过滤代理
jweb.gateway.adai.contextPath = /adai/
# 是否启用网关代理限流熔断
jweb.gateway.adai.sentinelEnable = true
# 被限流后跳转页面地址
#jweb.gateway.adai.sentinelBlockPage = /block
# 被限流后显示的json内容,如果有配置 sentinelBlockPage,则 sentinelBlockJsonMap 配置无效
#jweb.gateway.adai.sentinelBlockJsonMap ={"block":true}


# host 匹配示例。
jweb.gateway.adai2.enable = true
jweb.gateway.adai2.name = jweb-adai2
# 网关路由目标地址
# 支持{target.jweb.discovery.serviceName}的配置,动态选择健康的服务路由
jweb.gateway.adai2.uri = http://{adai}
jweb.gateway.adai2.hostStartsWith = adai.
# 是否启用网关代理限流熔断
jweb.gateway.adai2.sentinelEnable = true
# 被限流后跳转页面地址
#jweb.gateway.adai2.sentinelBlockPage = /block
# 被限流后显示的json内容,如果有配置 sentinelBlockPage,则 sentinelBlockJsonMap 配置无效
#jweb.gateway.adai2.sentinelBlockJsonMap ={"block":true}


# host 匹配示例。
jweb.gateway.adai3.enable = true
jweb.gateway.adai3.name = jweb-adai3
# 网关路由目标地址
# 支持{target.jweb.discovery.serviceName}的配置,动态选择健康的服务路由
jweb.gateway.adai3.uri = http://{adai}
jweb.gateway.adai3.hostStartsWith = adai3.
# 是否启用网关代理限流熔断
jweb.gateway.adai3.sentinelEnable = true
# 被限流后跳转页面地址
#jweb.gateway.adai3.sentinelBlockPage = /block
# 被限流后显示的json内容,如果有配置 sentinelBlockPage,则 sentinelBlockJsonMap 配置无效
#jweb.gateway.adai3.sentinelBlockJsonMap ={"block":true}

# 由于采用sun的HttpURLConnection连接代理,所以HOST头信息传递被限制了,影响服务重定向等
# 可以在启动时添加系统变量属性sun.net.http.allowRestrictedHeaders = true
# -Dsun.net.http.allowRestrictedHeaders = true

# PS
# - 针对网关代理,在压力测试时,发现存在大量的TIME_OUT状态连接,占用系统连接
# 可以参考链接优化linux系统:https://www.cnblogs.com/dadonggg/p/8778318.html
# - 在压测过程中,如果网关代理了自己,在 ab -c 1000 -n 10000 后直接卡信,jweb后台日志输出socket Read timeout。
# 原因未知,猜测可能是压测并发太大,占满链接数,导致代理的请求无法处理,请注意下。
#
# LINUX下压测代理性能说明:
# 测试链路:ab测试--->GW服务器---代理调用--->SERVICE服务器
# 被测机:两台服务器4cpu(i5-4590 3.30GHz)16G Centos 7。GW与SERVICE
# 测试机:4cpu(i5-4590 3.30GHz)16G Centos 7
# 命令:ab -c 1000 -n 10000  GW.targetUrl
# 接口:仅输出32个字符,无其它代码逻辑
# 结果:14000+- tps(GW -> SERVICE)
#
#--------jweb 网关路由配置 end--------






#-------- sentinel.properties 熔断限流配置 start--------
# 原配置文件为 classpath:sentinel.properties,这里启动统一重定向到jboot.properties
# 注意:该配置从sentinel.properties转移到这里,所有不支持jboot的${key}值替换
# 指定项目名称,String	null,非必需,
project.name=demo
# 指定应用的类型	int	0 (APP_TYPE_COMMON)	否	1.6.0 引入
# csp.sentinel.app.type
# 单个监控日志文件的大小	long	52428800 (50MB)	否
# csp.sentinel.metric.file.single.size
# 监控日志文件的总数上限	int	6	否
# csp.sentinel.metric.file.total.count
# 最大的有效响应时长(ms),超出此值则按照此值记录	int	4900	否	1.4.1 引入
# csp.sentinel.statistic.max.rt
# SPI 加载时使用的 ClassLoader,默认为给定类的 ClassLoader	String	default	否	若配置 context 则使用 thread context ClassLoader。1.7.0 引入
# csp.sentinel.spi.classloader
csp.sentinel.dashboard.server=localhost:8080
# 心跳包发送周期,单位毫秒 long,默认 null,非必需,若不进行配置,则会从相应的 HeartbeatSender 中提取默认值
# csp.sentinel.heartbeat.interval.ms=
# 本地启动 HTTP API Server 的端口号,int,默认值:8719,非必需,若端口冲突会自动向下探测可用的端口。
csp.sentinel.api.port=8720
# 指定心跳包中本机的 IP,String	- 默认值:空, 若不指定则通过 HostNameUtil 解析;该配置项多用于多网卡环境
# csp.sentinel.heartbeat.client.ip=
# 指定心跳包中本机IP获取时忽略的网口关键字(忽略大小写)
csp.sentinel.heartbeat.client.net.ignoredInterfaces=veth,docker,virtual
# 指定心跳包中本机IP获取时优先网段配置
csp.sentinel.heartbeat.client.net.preferredNetworks=192.168.2,192.168,172.27
#-------- sentinel.properties 熔断限流配置 end--------



#--------jboot 限流配置 start--------
jboot.sentinel.enable = true
jboot.sentinel.reqeustEnable = true
jboot.sentinel.datasource = nacos
jboot.sentinel.datasource.nacos.serverAddress=http://localhost:8848
jboot.sentinel.datasource.nacos.groupId=SENTINEL_GROUP
jboot.sentinel.datasource.nacos.dataId=${jweb.serviceName}-flow-rules
#--------jboot 限流配置 end--------


#-------jweb 杂项配置区 start--------
# 渲染器配置
# 扩展HTML模板解析引擎共享方法类
jweb.render.template.engine.shareMethodClasses=cc.jweb.adai.web.system.generator.utils.ModelUtils,cc.jweb.adai.web.system.generator.utils.GeneratorUtils
#-------jweb 杂项配置区 end--------

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325

引用

本节引用了Jboot的配置文档,更多详细可以前往 http://jboot.io/docs/config.html (opens new window)