1、 问题描述, 在加载使用如下
@Component
@ConfigurationProperties(prefix = “com.jdjr.response”)
@PropertySource(“classpath:/config/commonConfig.properties”)
public class CommonConfig {
}
加载到的属性中存在中文, 就会乱码。
2、 问题解决:
File -> Settings -> Editor -> File Encodings
将Properties Files (*.properties)下的Default encoding for properties files设置为UTF-8,将Transparent native-to-ascii conversion前的勾选上。
3、疑问
当上述的操作都做了, 重启服务, 再次访问还是乱码
遇到这种情况请将之前创建的properties 文件删除, 在创建文件,添加属性即可。