I am trying to run a spring boot application which uses annotation configuration, below is the WebConfig.java file,
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"com.kumar.codebuzz"})
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new SecurityHandlerInterceptor()).addPathPatterns("/v1/app/*").excludePathPatterns("/v1/generateOTP", "/v1/validateOTP", "/users/signUp");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/swaggerui/**")
.addResourceLocations("classpath:/swaggerui/");
registry.addResourceHandler("/webview/**")
.addResourceLocations("classpath:/webview/");
}
@Bean
public ViewResolver configureViewResolver() {
InternalResourceViewResolver viewResolve = new InternalResourceViewResolver();
viewResolve.setPrefix("/WEB-INF/views/");
viewResolve.setSuffix(".jsp");
return viewResolve;
}
}
i am not able to start the application, below is the stack trace,
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultServletHandlerMapping' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'defaultServletHandlerMapping' threw exception; nested exception is java.lang.IllegalArgumentException: A ServletContext is required to configure default servlet handling
not able to figure out the issue.
Thanks,