Facing below exception while deploying Spring WebFlux application as war file in tomcat.Extended with AbstractAnnotationConfigDispatcherHandlerInitializer and implemented getConfigClasses method as below.
Application
@SpringBootApplication
public class TestSpringApplication extends AbstractAnnotationConfigDispatcherHandlerInitializer {
public static void main(String[] args) {
SpringApplication.run(TestSpringApplication.class, args);
}
@Override
protected Class<?>[] getConfigClasses() {
return new Class[]{
WebConfig.class
};
}
Controller
@Controller
public class TestSpringController {
@RequestMapping("/test")
public Mono<String> hello(Model model){
return Mono.just("account");
}
}
Note : account.html is placed under resources/templates
Exception
java.lang.IllegalStateException: Could not resolve view with name 'account'.
at org.springframework.web.reactive.result.view.ViewResolutionResultHandler.lambda$resolveViews$3(ViewResolutionResultHandler.java:276) ~[spring-webflux-5.0.1.RELEASE.jar:5.0.1.RELEASE]
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:107) [reactor-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]