Andrunevchyn

Andrunevchyn


notes and issue research

October 2017
M T W T F S S
« Jan   Dec »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Categories


Spring 5 + WebFlux without SpringBoot

Andriy AndrunevchynAndriy Andrunevchyn

I don’t like SpringBoot because of hidden dependencies and unknown springconfigs behind annotations. But there is one more problem with SpringBoot – as usual latest examples from Pivotal (and others as well) are written based on SpringBoot and sometimes it’s not possible easily to figure out how properly to set up plain Spring config. I’m running new project based on WebFlux and it should be old school war file which we can deploy on any webserver. So task is to configure WebFlux without SpringBoot. There are two ways  – mapping based on annotation which could be done even based on WebMvcConfigurer like this

or second approach – mapping based on routes. Unfortunately there is no clear explanation how to do it without SpringBoot. I found only mention about such kind of config in book “Spring 5 Recipes” so I took  it and added like

And guess what? It didn’t work for me! I spend some time on investigation and figured out my mapping is not correct I configured route like

 

But the proper path actually should include war file name because I deployed war file and tomcat run project in folder with the same name so that the proper route is

As usual Spring has many way to configure the same thing so you  can also write this route like this

Also you could do like this

but it’s not really good idea cause urls http://host:port/testproject/echo and http://host:port/testproject/path/echo will be managed by the same handler

Actually I don’t understand why it was written like that. Why do we need project name on path? If we check class RequestPatternPredicate which we use for matching we will see the following

Issue happens because in method matchAndExtract we pass as parameter container with the full path instead relative path. I don’t see other way except extending this class and overriding method test (( If I do it I’ll publish code later

The funny thing is  – plain annotation config works fine with the second approach either, no need to configure path with project name.

Comments 0
There are currently no comments.

Leave a Reply