I am trying to configure Spring / Data / JPA Spring Domain / Cluster to automatically convert (String) to domain classes.
My project uses Java Config (therefore no xml).
In my WebConfig, I have:
@Configuration @EnableWebMvc public class WebConfig extends WebMvcConfigurerAdapter { @Override public void addFormatters(FormatterRegistry registry) { registry.addConverter(new DomainClassConverter<DefaultFormattingConversionService>((DefaultFormattingConversionService) registry)); } }
This looks like a successful DomainClassConverter connection, as I see it inside the print conversion service:
ConversionService converters = ..<default converters>.. o rg.springframework.data.repository.support.DomainClassConverter@ 6ea4ce0d, org.springframework.core.convert.support.IdToEntityConverter@5d3 f03b, o rg.springframework.core.convert.support.ObjectToObjectConverter@ 1d40b47a
But when sending a nested form (Order with client ref), the Client is not automatically converted, and therefore I get:
Failed to convert property value of type java.lang.String to required type org.mycomp.domain.Customer for property customer; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.mycomp.domain.Customer] for property customer: no matching editors or conversion strategy found
I wonder if I'm doing something wrong here?
source share