读取properties配置文件,value值为中文时出现乱码

已确保idea工具默认设置都是UTF-8格式:
 
 
然后在配置类上,指定编码:
@PropertySource(value = "classpath:short_message.properties",encoding = "UTF-8")
 
 
@Data
@Component
@PropertySource(value = "classpath:short_message.properties",encoding = "UTF-8")
@ConfigurationProperties()
public class ShortMessageConfig {
    /**
     * 阿里云访问控制台寻找 KeyId
     */
    private String accessKeyId;
 
    /**
     * 阿里云访问控制台寻找 KeySecret
     */
    private String accessKeySecret;
 
    /**
     * 产品名称
     */
    private String product;
 
    /**
     * 产品域名
     */
    private String domain;
 
    /**
     * 地域
     */
    private String region;
 
    /**
     * 签名名称
     */
    private String signName;
 
    /**
     * 模版CODE
     */
    private String templateCode;
}
原文地址:https://www.cnblogs.com/dingxu/p/9849602.html