這是由于spring
的配置文件帶有命名空間
需要在原有的基礎(chǔ)上進(jìn)行一點(diǎn)處理
Element rootElm = doc.getRootElement();
System.out.println(rootElm.getName());
HashMap map=new HashMap();
map.put("design",rootElm.getNamespaceURI());
XPath xPath=doc.createXPath("http://design:bean[@id='dataSource']/design:property[@name='url']/design:value");
xPath.setNamespaceURIs(map);
Element element = (Element) xPath.selectSingleNode(doc);
System.out.println(element.getText());
if(element!=null){
element.setText("jdbc:oracle:thin:@"+dataBaseIp+":1521:orcl");
}