Skip to content

Clarify documentation on registering custom converters #1625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tomek82 opened this issue Sep 27, 2023 · 1 comment
Closed

Clarify documentation on registering custom converters #1625

tomek82 opened this issue Sep 27, 2023 · 1 comment
Labels
type: documentation A documentation update

Comments

@tomek82
Copy link

tomek82 commented Sep 27, 2023

In https://docs.spring.io/spring-data/jdbc/docs/current/reference/html/#jdbc.custom-converters.configuration the suggested way of registering custom converters is to subclass AbstractJdbcConfiguration. However doing so makes it depend on JDBC specific beans not available in test slices like JsonTest.

The solution that worked for me was to create a JdbcCustomConversions bean instead like this:
@Bean public JdbcCustomConversions customConversions() { return new JdbcCustomConversions(List.of(new MyCustomConverter())); }

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 27, 2023
@schauder schauder added type: documentation A documentation update type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 28, 2023
@mp911de mp911de removed the type: task A general task label Sep 28, 2023
@mp911de
Copy link
Member

mp911de commented Sep 28, 2023

However doing so makes it depend on JDBC specific beans not available in test slices like JsonTest.

From your description it sounds as if you're setting up a configuration that doesn't match your test slice setup as you would pull in dependencies that shouldn't be declared with that configuration in the first place.

Part of the problem is also that our documentation doesn't include Spring Boot-specifics as we do not depend on Boot, rather it is the other way around.

Generally, we should align our documentation to explain specifics of CustomConversions along the lines of https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mongo.property-converters.value-conversions

MongoDB specifically calls out:

If you want to rely on Spring Boot to bootstrap Data MongoDB, but still want to override certain aspects of the configuration, you may want to expose beans of that type. For custom conversions you may eg. choose to register a bean of type MongoCustomConversions that will be picked up the by the Boot infrastructure. To learn more about this please make sure to read the Spring Boot Reference Documentation.

@mp911de mp911de added this to the 3.2 GA (2023.1.0) milestone Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

4 participants