Java项目使用@Value标签读取配置文件的中文乱码问题的解决
1.在配置spring.xml文件时,声明所需的?.properties文件时直接使用"utf?8"编码:
2.如果在所需类上注入可使用以下方式来声明编码格式:
@Component @PropertySource(value = "classpath:xxx.properties",encoding = "utf-8") public class test {
@Value("${a}") private String a; }