Jackson mismatched input error
Suppose you are trying to do something like:
@Bean
public MyConfiguration myConfiguration() throws IOException {
ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());
return yamlMapper.readValue(new File("configuration.yml"), MyConfiguration.class);
}
But the output is something like:
com.fasterxml.jackson.databind.exc.MismatchedInputException
There are at least two reasons:
- Configuration file does not exist;
- Setters for
MyConfiguration.classare named incorrectly or cannot be accessed.