Spring Boot--05--配置文件Properties

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


配置文件Properties



import com.alibaba.fastjson.JSON;


import com.tuzhanai.cbsp.business.common.utils.JSRValidatorUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;


@ConfigurationProperties(prefix = "weixin.ftp.upload")
@Configuration
@Data
@Slf4j
public class weixinProperties implements InitializingBean {

    @NotBlank(message = "ip must not null")
    private String ip;
    @NotNull(message = "port must not null")
    private Integer port;
    @NotBlank(message = "user must not null")
    private String user;
    @NotBlank(message = "pwd must not null")
    private String pwd;
    @NotBlank(message = "uploadDir must not null")
    private String uploadDir;

    /**
     * 相关文件名
     */
    /**上传的基础数据文件名: FK00006D.CAR*/
    @NotBlank(message = "uploadFileName must not null")
    private String uploadFileName;
    /**存储本地上传文件临时文件夹*/
    @NotBlank(message = "uploadLocalDir must not null")
    private String uploadLocalDir;

    private Long fizeSize;

    @NotBlank(message = "modelNo must not null")
    private String modelNo;

    @NotBlank(message = "page must not null")
    private String page;

    @NotBlank(message = "miniprogramState must not null")
    private  String miniprogramState;

    private Long clearday;

    @Override
    public void afterPropertiesSet() throws Exception {
        String config = JSON.toJSONString(this);
        log.info("weixin文件,配置属性:{}",config);
        try {
            JSRValidatorUtil.validate(this);
        } catch (Exception e) {
            throw new IllegalArgumentException("weixin配置文件是否存在必填项为空!");
        }
    }

}

nacos 配置

#weixin直接下发批量文件
weixin:
  ftp:
    upload:
      ip: 192.168.2.51
      user: tuzhan
      pwd: Tuzhan@2021
      port: 21
      uploadDir: /home/FTP/notice/MN00001/
      uploadLocalDir: /home/FTP/notice/MN00001/
      uploadFileName: MN00001.{0}.025.{1}.MSG
      fizeSize: 10000
      modelNo: vMYQzNt1mfEmw0-tUiYnBri_sG5vOo2csfW09pd0Lao
      page: pages/poster/index?taskId=
      miniprogramState: trial
      clearday: 7
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值