简体   繁体   English

杰克逊(Jackson)无法在课程yyy上找到属性“ xxx”

[英]Jackson Unable to find property 'xxx' on class: yyy

I am trying to use Jackson to parse a YAML file into an object, using the following code: 我正在尝试使用杰克逊使用以下代码将YAML文件解析为对象:

yaml.loadAs(userFilterConfigInputStream, UserFilterConfiguration.class);

I get the following error: 我收到以下错误:

Unable to find property 'xxx' on class: com.yyy... 在类com.yyy上找不到属性“ xxx”。

I don't understand though, because my constructor seems clear: 我不明白,因为我的构造函数看起来很清楚:

public UserFilterConfiguration(
        @JsonProperty("groups") List<String> groups)

I have tried replacing List<String> by String or String[] , I still got the same error. 我尝试用StringString[]替换List<String> ,但仍然遇到相同的错误。

In the end I managed to make it work by replacing yaml.loadAs... by 最后,我设法通过将yaml.loadAs...替换为

ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
userFilterConfig = mapper.readValue(configFile, UserFilterConfiguration.class);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM