最近测试某个老系统的时候,启动的时候发@Value注入的中文是乱码,文件使用GBK/UTF-8的时候均会出现乱码问题,但是spring配置文件里面注入的占位符并没有这个问题,bean文件设置了file-encoding="UTF-8"亦如此。

经查,可通过如下方式解决:

@Component
@PropertySource(value = "classpath:conf/spider.properties",encoding = "utf-8")
@Getter
public class SpiderConfig {
    @Value("${a}")
    private String a;
    @Value("${b}")
    private String b;
}

亦或是

 

相关文章:

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