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;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值