SpringBoot读取Properties配置文件中文乱码解决方法

问题:

在配置文件中配置了一个中文值

 然后通过@Value读取值读取出来是乱码,无法使用。

 

 解决方案:

将获取的字符串编码进行转换

this.testStr = new String(testStr.getBytes(StandardCharsets.ISO_8859_1),StandardCharsets.UTF_*);

 成功拿到原值SpringBoot读取Properties配置文件中文乱码解决方法_第1张图片

 SpringBoot读取Properties配置文件中文乱码解决方法_第2张图片

 

你可能感兴趣的:(spring,boot,java,spring)