I am trying to use Jackson to parse a YAML file into an object, using the following code:
yaml.loadAs(userFilterConfigInputStream, UserFilterConfiguration.class);
I get the following error:
Unable to find property 'xxx' on class: com.yyy...
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.
In the end I managed to make it work by replacing yaml.loadAs...
by
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
userFilterConfig = mapper.readValue(configFile, UserFilterConfiguration.class);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.