У меня есть такое хранилище :
public interface ApartmentRepository
extends PagingAndSortingRepository<Apartment, Long> {
Page<LandlordPageApartment> findAllByOwnerId(long ownerId, Pageable pageable);
}
И когда я его использую, возникает исключение : org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [Apartment] to type [LandlordPageApartment]
Здесь я определяю мой конвертер :
@Component
public class ApartmentToLandlordPageApartmentConverter implements Converter<Apartment, LandlordPageApartment> {
@Override
public LandlordPageApartment convert(Apartment apartment) {
// some conversion
}
}
Регистрация преобразователя :
@Configuration
@EnableWebMvc
public class AbsWebMvcConfigurer implements WebMvcConfigurer {
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(apartmentToLandlordPageApartmentConverter());
}
@Bean
public ApartmentToLandlordPageApartmentConverter
apartmentToLandlordPageApartmentConverter() {
return new ApartmentToLandlordPageApartmentConverter();
}
// ...
}
Что я делаю не так?