Spring WebFluxアプリケーションをTomcatにwarファイルとしてデプロイする際に以下の例外が発生しました。AbstractAnnotationConfigDispatcherHandlerInitializerを使用し、getConfigClassesメソッドを実装しました。WARとしてデプロイする際、SpringブートWebFluxで表示例外を解決できません
アプリケーション
@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
public class TestSpringController {
@RequestMapping("/test")
public Mono<String> hello(Model model){
return Mono.just("account");
}
}
注account.htmlは、リソース/テンプレートの下に配置され
例外
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]
ありがとうございます。5.0.1バージョンのAbstractServletHttpHandlerAdapterInitializerにバグがあり、ここで提案されているworkaroudを試していました。https://stackoverflow.com/questions/46325632/how-to-activate-spring-security- in-a-webflux-war-applicationで動作するようにはできませんでした –
他の質問はSpring Frameworkのみを考慮しています。ここでは、Springのブート機能を使用しようとしています。これは別の使用例です。 –