springBoot配置文件使用说明bootstrap.yml
服务和端口
server:
port: 8030
swagger开关
swagger:
enable: true
spring节点
spring:
application:
name: XXX
cloud:
nacos:
discovery:
server-addr: XXX.XXX.XXX.XXX:8010
register-enabled: false
config:
file-extension: yml
server-addr: XXX.XXX.XXX.XXX:8010
datasource:
url: XXX
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
username: XXX
password: XXX
min-idle: 5
max-active: 20
validation-quey: select 1
connection-init-sqls: set names utf8mb4
test-on-borrow: false
test-while-idle: true
test-on-return: false
redis:
password: XXX
jedis:
pool:
max-active: 5
max-wait: -1
max-idle: 5
min-idle: 0
sentinel:
master: mymaster
nodes: XXX.XXX.XXX.XXX:8190,XXX.XXX.XXX.XXX:8191,XXX.XXX.XXX.XXX:8192
mybatis-plus节点
mapper-locations: classpath:com/XXX/XXX/XXX/dao/mapper/*.xml
type-aliases-package: com.XXX.XXX.XXX.dao.entity
configuration:
map-underscore-to-camel-case: true
代理proxy节点
http-proxy: &proxy
enable: true # 是否开启本机代理直连外网, 部署至uat及生产环境时应置为false
proxy-host: XXX.XXX.XXX.XXX# 本机直连时的代理ip
proxy-port: 8080 # 本机直连时的代理port
自定义节点
alipay:
gateway-host: openapi.alipay.com
server-url: https://openapi.alipay.com/gateway.do
app-id: XXX
sign-type: RSA2
version: 1.0
private-key: XXX
alipay-public-key: XXX
aes-key: XXX
http-proxy: *proxy
自定义节点的使用
添加对应的配置类
@Data
@Slf4j
@Configuration
@ConfigurationProperties(prefix = "alipay")
public class AlipayConfig {
private String gatewayHost;
private String appId;
private String signType;
private String version;
private String privateKey;
private String alipayPublicKey;
private String aesKey;
private HttpProxyConfig httpProxy;
@PostConstruct
public void init() {
Config config = new Config();
config.appId = appId;
config.alipayPublicKey = alipayPublicKey;
config.encryptKey = aesKey;
config.gatewayHost = gatewayHost;
config.protocol = "https";
config.merchantPrivateKey = privateKey;
config.signType = "RSA2";
config.ignoreSSL = true;
if (httpProxy.isEnable()) {
config.httpProxy = "http://" + httpProxy.getProxyHost() + ":" + httpProxy.getProxyPort();
}
Factory.setOptions(config);
}
}
配置类使用
@Autowired
AlipayConfig alipayConfig;