日期:2014-05-20 浏览次数:20823 次
private ObjectMapper mapper;
private List<AppConfig> appConfig;
public AppConfigController()
{
String propsFile = AppConfigController.class.getResource("/").toString().replace("file:", "") + "appConfig.cfg";
this.mapper = new ObjectMapper();
this.mapper.setAnnotationIntrospector(new NopAnnotationIntrospector());
try
{
propsFile = java.net.URLDecoder.decode(propsFile,"utf-8");
logger.info("获取到配置文件路径{}", new File(propsFile).getAbsolutePath());
this.appConfig = mapper.readValue(new File(propsFile), new TypeReference<List<AppConfig>>()
{
});
} catch (Exception e)
{
e.printStackTrace();
logger.warn(e.getMessage() + "配置文件路径:{}", propsFile);
}
}
------解决方案--------------------
解决了?那就结贴吧