记SpringBoot读取配置文件乱码问题

SpringBoot读取配置文件,先后设置了
banner.charset=UTF-8
server.tomcat.uri-encoding=UTF-8
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
spring.messages.encoding=UTF-8
 
  
@RequestMapping(value = "/", produces="text/plain;charset=UTF-8")
都无效,最后发现
 
  
@ConfigurationProperties(prefix = "book")
@PropertySource(value = "classpath:book.properties", encoding = "UTF-8")
public class BookBean {
    private String name;
    private String author;
    private String price;
}
在注解上设置编码格式就好了,真是坑到我了

你可能感兴趣的:(SpringBoot)