通过@PropertySource注解读取指定配置文件
@RestController
@RequestMapping
@PropertySource(value = "classpath:{exception.properties}", encoding = "UTF-8")
public class TestPropertiesController {
@Autowired
Environment env;
@GetMapping("testEnv")
public String testENV(HttpServletRequest request) {
return env.getProperty("DEMO_00001");
}
}