解决SpringBoot中properties配置文件乱码问题

2024-11-01 11:04:23

1、我们通过properties文件读取中文:server.port=8888person.last-name=帅哥

解决SpringBoot中properties配置文件乱码问题

3、原因是在idea使用的utf-8,而properties文件使用的ascii码。点击File-Setting->File Encodings

解决SpringBoot中properties配置文件乱码问题

5、更改这个配置完成之后,properties文件中的中文乱码了,需要重新修改。

解决SpringBoot中properties配置文件乱码问题

6、重新编辑properties文件之后再次运行springboot测试类,这样中文读取就正常了。

猜你喜欢