spring-projects / spring-projects/spring-data-rest
Provide a configuration mechanism that does not require subclassing RepositoryRestMvcConfiguration [DATAREST-621]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Andy Wilkinson opened DATAREST-621 and commented
A typical Spring Boot application with Spring Data REST on the classpath will include RepositoryRestMvcConfiguration via auto-configuration. This auto-configuration is carefully ordered so that RepositoryRestMvcConfiguration is processed after Boot's Jackson auto-configuration. This allows JacksonAutoConfiguration to create its @Primary ObjectMapper which is conditional on there being no ObjectMapper beans in the context.
If a user subclasses RepositoryRestMvcConfiguration the ordering described above is broken . User configuration is always processed before auto-configuration, so RepositoryRestMvcConfiguration is processed before JacksonAutoConfiguration. This prevents the creation of the @Primary ObjectMapper as RepositoryRestMvcConfiguration has created its two ObjectMapper beans before JacksonAutoConfiguration is processed. The presence of multiple ObjectMapper beans without one being @Primary then causes autowiring failures.
The proposed solution is to separate customising Spring Data RESTs configuration from its bean declarations. One way to achieve this would be to adopt a WebMvcConfigurer-like pattern. Another would be to provide a separate @Bean method-free class to subclass
Affects: 2.4 M1 (Gosling)
Reference URL: https://github.com/spring-projects/spring-boot/issues/3439
Issue Links:
- DATAREST-594 Extending SpringBootRepositoryRestMvcConfiguration removes jacksonObjectMapper bean
("is duplicated by") - DATAREST-594 Extending SpringBootRepositoryRestMvcConfiguration removes jacksonObjectMapper bean
3 votes, 3 watchers
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.