Main.java
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
Model k = mapper.readValue(new File(PATH), Model.class);
Model.java
public class Model {
@JsonProperty
private Specs details;
private class Specs{
@JsonProperty
private String topic;
@JsonProperty
private String id;
@JsonProperty
private List<String> list;
}
}
yamlfile.yaml
details:
topic: "test"
id: "123"
servers: [
"test2"
]
Я запускаю main.java и получите исключение:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "details" (class Model), not marked as ignorable (0 known properties: ])
at [Source: src/main/config/yamlfile.yaml; line: 2, column: 3] (through reference chain: Model["details"])
Я понятия не имею, что я делаю не так, и, похоже, не могу найти проблему.Почему это не признается?