I want to make some "generic controllers" but I don't want to make a new class file and extends. I just want to "register" them on a configuration class.

Can I do something like these? There's an alternative for this?

@Configuration
public class WebConfig {

@Controller // or @Bean
@RequestMapping("/sex")
public Controller<Sex, Long> sexController() {
return new GenericController<Sex, Long>() {
};
}
}

Thanks