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前的勾选上。 
Springboot 在IDEA读取properties配置文件的中文乱码问题

3、疑问

当上述的操作都做了, 重启服务, 再次访问还是乱码 
遇到这种情况请将之前创建的properties 文件删除, 在创建文件,添加属性即可。

相关文章:

  • 2021-05-20
  • 2022-01-21
  • 2022-12-23
  • 2021-04-20
  • 2021-12-06
  • 2021-12-26
  • 2022-12-23
  • 2021-09-07
猜你喜欢
  • 2021-11-20
  • 2021-07-04
  • 2021-08-16
  • 2021-10-19
  • 2022-01-25
  • 2021-09-16
相关资源
相似解决方案