Provide auto-configuration for Spring HATEOAS's new WebFlux integration
See original GitHub issueA non-exhaustive list of things to consider:
- Auto-configuration ordering
spring-boot-starter-hateoas
is currently MVC specific (it depends onspring-boot-starter-web
)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:11 (10 by maintainers)
Top Results From Across the Web
Spring HATEOAS - Reference Documentation
This project provides some APIs to ease creating REST representations that follow the HATEOAS principle when working with Spring and especially ...
Read more >OpenAPI 3 Library for spring-boot
The library uses spring-boot application auto-configured packages to scan for the following annotations in spring beans: OpenAPIDefinition and ...
Read more >spring-boot ReactiveClientRegistrationRepository not found
The way I understand spring-boot-autoconfigure it should use the ReactiveOAuth2ClientAutoConfiguration , as in the yml-file the required ...
Read more >spring-projects/spring-hateoas - Gitter
Then it would not be necessary for a custom type to implement and provide a separate (auto) configuration. I probably overlook something or...
Read more >Documentation for the spring Generator
#CONFIG OPTIONS ; groupId, groupId in generated pom.xml ; hateoas, Use Spring HATEOAS library to allow adding HATEOAS links ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
TL;DR: I think we should move this out of 2.2.x or perhaps even close this.
In addition to the ongoing discussions involving @odrotbohm and @bclozel related to media type aliasing which are not going to be resolved in the Framework 5.2/Boot 2.2 timeframe, I am now of the opinion that WebFlux-based auto-configuration will be more of a hinderance than a help to users.
Setting aside the
HttpMessageConverter
customization that Boot optionally performs and which is servlet-specific, the auto-configuration is reduced to a single annotation:The expanded range of media types that are supported by Spring HATEOAS mean that Boot auto-configuring HAL and only HAL is harder to justify. As soon as the user specifies
@EnableHypermediaSupport
(which they are now more likely to want to do), all of the auto-configuration other than theHttpMessageConverter
customization backs off. WebFlux-based auto-configuration will have no equivalentHttpMessageConverter
auto-configuration so in many cases it would back off entirely as the user specifies@EnableHypermediaSupport
with their chosen media types.Adding WebFlux support would also mean that the starter makes little sense any more. It currently contains three dependencies:
org.springframework.boot:spring-boot-starter-web
org.springframework.hateoas:spring-hateoas
org.springframework.plugin:spring-plugin-core
To allow the starter to apply to be web stacks, 1 would be removed. Furthermore 3 is no longer needed as
spring-plugin-core
is now a required dependency ofspring-hateoas
. This would leave the starter with a single module, 2, with the expectation that it’s used in combination withspring-boot-starter-web
orspring-boot-starter-webflux
. A single module starter doesn’t serve any purpose so it would make sense to remove it.As I wrote the above, I realised that much of the same logic could be applied to MVC too. Once the media type aliasing discussion has been resolved (hopefully in the Framework 5.3 timeframe), it may make sense to deprecate Boot’s auto-configuration for Spring HATEOAS on the servlet-based web stack. The discussion will hopefully result in a better alternative to Boot’s
HttpMessageConverter
customization which will leave it in the same situation as WebFlux-based auto-configuration where it’s just auto-configuring a single annotation that will back of entirely as soon as the user tunes things. There may even be a case for deprecating the auto-configuration in 2.2. There’d be no replacement forspring.hateoas.use-hal-as-default-json-media-type
but with hindsight adding that property may have been a mistake anyway. Deprecation now would help to reduce confusion about what starter to use when using HATEOAS with WebFlux with the answer being that Spring HATEOAS should be used directly without any need for a starter as it’s a single dependency.What do you think, @odrotbohm and @gregturn? My reasoning above is based on there actually being very little for Boot to auto-configure these days. If there are, in fact, some more new features for which auto-configuration would make sense then my reasoning will no longer apply.
@wilkinsona when I do this, I have managed to get things working with WebFlux…
Presumably, because this takes Spring MVC off the classpath and puts WebFlux on the classpath, Spring HATEOAS itself is able to pick the right set of beans to register itself properly.