使用Dom4j解析xml出现非法反射异常,求大佬帮忙解决下

weixin_42127327 weixin_42127327 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
public class TestDom4j {

public static void main(String[] args) throws Exception{
selectSin();

}
//查询p.xml下的第一个name元素
public static void selectSin() throws Exception {
SAXReader sr=new SAXReader();//创建解析器
Document document=sr.read("src/p.xml");
Element element =document.getRootElement();//得到根元素
List<Element> list=element.elements("p1");
Iterator<Element> i=list.iterator();
while(i.hasNext()) {
Element name=i.next();
String str=name.getText();
System.out.println(str);
}
}
}
异常
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.dom4j.io.SAXContentHandler (file:/D:/eclipse-workspace/day06/lib/dom4j-1.6.1.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getEncoding()
WARNING: Please consider reporting this to the maintainers of org.dom4j.io.SAXContentHandler
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
weixin_42127327
Web 开发 81,107 成员 341,720 内容