当前位置: 首页 > 工具软件 > Jaxen > 使用案例 >

报错java.lang.NoClassDefFoundError: org/jaxen/JaxenException

邹华皓
2023-12-01

在前端传参xml格式的字符串时

Document document = null;
        SAXReader reader = new SAXReader();
        try {
            document = reader.read(new ByteArrayInputStream(new String(in
                    .getBytes("UTF-8"), "UTF-8").getBytes("UTF-8")));
        } catch (DocumentException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
String nodeValue;
        if (document.selectSingleNode(url) == null) {
            nodeValue = "";
        } else {
            nodeValue = document.selectSingleNode(url).getText();
        }
        return nodeValue;

获取子节点时报错,我时采用dom4j解析的,经过查询,缺少依赖,加上就好了

		<dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>2.10.1</version>
        </dependency>
        <dependency>
            <groupId>jaxen</groupId>
            <artifactId>jaxen</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
        </dependency>
 类似资料: