If you are using Spring Boot, this is the reason that you should not use WebMvcConfigurationSupport
.
The best practice, you should implement interface org.springframework.core.convert.converter.Converter
, and with annotation @Component
. Then Spring Boot will auto load all Converter
‘s bean. Spring Boot code
@Component
public class GenderEnumConverter implements Converter<String, GenderEnum> {
@Override
public GenderEnum convert(String value) {
return GenderEnum.of(Integer.valueOf(value));
}
}