错误日志:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'converter' defined in class path resource
[...../spring/controller/PsvJackson2HttpMessageConverter.class]:
No matching factory method found: factory bean 'psvJackson2HttpMessageConverter';
factory method 'converter()'.
Check that a method with the specified name exists and that it is non-static.
这是配置类:
@Configuration
public class PsvJackson2HttpMessageConverter extends WebMvcConfigurationSupport {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(converter());
converters.add(new ByteArrayHttpMessageConverter());
converters.add(new StringHttpMessageConverter());
super.addDefaultHttpMessageConverters(converters);
}
@Bean
MappingJackson2HttpMessageConverter converter() {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
converter.setObjectMapper(objectMapper);
return converter;
}
}
不知道这里有什么问题。
答案 0 :(得分:0)
以下是您可以做的事情:
例如,这是配置类:
UITableView *tableView = (UITableView *)[self.view viewWithTag:1];
这是转换器类:
@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void configureMessageConverters(final List<HttpMessageConverter<?>> converters) {
converters.add(new CustomMappingJackson2HttpMessageConverter());
super.configureMessageConverters(converters);
}
}