I got a working spring boot rest service. When the path is wrong it doesn\'t return anything. No response At all. At the same time it doesn\'t throw error either. Ideally I expe
I know this is an old question but here is another way to configure the DispatcherServlet
in code but not in the main class. You can use a separate @Configuration
class:
@EnableWebMvc
@Configuration
public class ExceptionHandlingConfig {
@Autowired
private DispatcherServlet dispatcherServlet;
@PostConstruct
private void configureDispatcherServlet() {
dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
}
}
Please not that this does not work without the @EnableWebMvc
annotation.