实体类
package com.springboot.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.time.Duration;
@Data
@Component
@ConfigurationProperties(prefix = "servers")
public class ServerConfig {
private String ipAddress;
private int port;
private long timeout;
private Duration serverTimeOut;
}
yml配置
servers:
ip_address: 192.168.0.1
PORT: 88
time-out: 123
serverTimeOut: 3
输出
千分之三毫秒
ServerConfig(ipAddress=192.168.0.1, port=88, timeout=123, serverTimeOut=PT0.003S)
Duration
方法里面可以自定义显示类型,时分秒等
输出
ServerConfig(ipAddress=192.168.0.1, port=88, timeout=123, serverTimeOut=PT3H)
3H 3小时
DataSize
数据空间的大小
private DataSize dataSize;
输出
10个比特
ServerConfig(ipAddress=192.168.0.1, port=88, timeout=123, serverTimeOut=PT3H, dataSize=10B)
修改大小在后缀添加即可