无法解析导入com.fasterxml.jackson.xml

时间:2016-12-09 07:26:49

标签: java spring maven spring-mvc jackson

我正面临错误The import com.fasterxml.jackson.xml cannot be resolved. XmlMapper cannot be resolved to a type
import com.fasterxml.jackson.xml.XmlMapper;

我的pom:

<modelVersion>4.0.0</modelVersion>
         <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>

版本有问题吗?杰克逊核心和数据绑定的其他进口似乎完全正常。仅在xml的情况下会发生这种情况。

3 个答案:

答案 0 :(得分:2)

尝试添加

<dependency>
    <groupId>com.fasterxml</groupId>
    <artifactId>jackson-xml-databind</artifactId>
    <version>0.6.2</version>
</dependency>

<dependency>
    <groupId>com.fasterxml.jackson.dataformat</groupId>
    <artifactId>jackson-dataformat-xml</artifactId>
    <version>2.8.5</version>
</dependency>

答案 1 :(得分:2)

这是一个具有不同Maven坐标的旧jar。

尝试:

<dependency>
    <groupId>com.fasterxml</groupId>
    <artifactId>jackson-xml-databind</artifactId>
    <version>0.6.2</version>
</dependency>

答案 2 :(得分:0)

添加

import com.fasterxml.jackson.dataformat.xml.XmlMapper;

和{{1}}

如需更多参考,请访问:https://github.com/FasterXML/jackson-dataformat-xml