Initial wrong code

public class AppConfig {
    @Bean
    public ModelMapper modelMapper(){

        return new ModelMapper();
    }
}

Solution

I have not properly registered my Bean. Whilst I declared my ModelMapper as bean method, I have not annotated my class with @Configuration.

@Configuration
public class AppConfig {
    @Bean
    public ModelMapper modelMapper(){

        return new ModelMapper();
    }
}