katharsis configured with spring xml

177 Views Asked by At

It looks, from the source code, that Katharsis-spring module will only work with spring boot.

My question then, is it possible to configure a spring project in xml and load Katharsis without spring boot?

If so, how would you need to configure katharsis in spring xml?

Has anyone done this before and willing to share an example?

Thanks.

2

There are 2 best solutions below

0
JoshR On BEST ANSWER

With version 2.8.1 of katharsis, it is quite a challege to get this configured just in xml. So I looked at the master branch of the project and found that there are going to be some new features which will make it easier to configure with spring xml. I have created a sample project here you can use as reference for configuration:

Sample Spring/Katharsis Project with XML configuration

In the sample project I added the SpringServiceDiscovery class, and modified the KatharsisBoot class to make the configuration easier. With the next release of this project, I should be able to remove these 2 classes completely, and use the classes that come with katharsis.

The beans I needed to add to my root-context.xml file were the following:

io.katharsis.spring.KatharsisFilterV2
io.katharsis.spring.ErrorHandlerFilter
com.springkatharsisxml.katharsis.boot.KatharsisBoot
io.katharsis.queryParams.QueryParamsBuilder
io.katharsis.resource.registry.ConstantServiceUrlProvider
io.katharsis.queryParams.DefaultQueryParamsParser
io.katharsis.module.CoreModule
io.katharsis.resource.field.ResourceFieldNameTransformer
io.katharsis.spring.boot.KatharsisSpringBootProperties

I also needed to expose the jackson objectMapper bean, as it's not done so by default in xml.

I also used the org.springframework.web.filter.DelegatingFilterProxy for the katharsisFilter and errorHandlerFilter.

1
Christian Bongiorno On

Only work with Spring boot? That doesn't seem possible. Just @Import(KatharsisConfigV2.class) on any configuration in your code and it should work.

As for xml config: By design, if it can be done in code it can be done in config.

Try that and let me know how you make out