1. 工程目录结构
2. 解析 xml文件节点
@Override
public void onApplicationEvent(ContextRefreshedEvent arg) {
//初始化完成
Document doc = loadConfig();//读取配置
initSubscriber(doc.getRootElement().elements("subscriber"));
initPublisher( doc.getRootElement().elements("publisher"));
}
private Document loadConfig() {
Document doc = null;
SAXReader reader = new SAXReader();
try {
doc = reader.read(new File("./config/config.xml"));
} catch (DocumentException e) {
e.printStackTrace();
}
return doc;
}
/**
* unix时间戳转日期
* @param timestamp
* @return
*/
protected Date timestamp2date(long timestamp) {
Date d = new Date();
d.setTime(timestamp);
return d;
}