'Spring Boot: The method add(Converter) in the type Set<Converter> is not applicable for the arguments (...)
When trying to add something to the converters HashSet in ConversionConfig.java, I get the following error in RED:
Error:
The method add(Converter) in the type Set<Converter> is not applicable for the arguments (RoomEntityToReservationResponseConverter)
ConversionConfig.java:
@Configuration
public class ConversionConfig {
@SuppressWarnings("rawtypes")
private Set<Converter> getConverters() {
Set<Converter> converters = new HashSet<Converter>();
converters.add(new RoomEntityToReservationResponseConverter());
return converters;
}
@Bean public ConversionService conversionService() {
ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();
bean.setConverters(getConverters());
bean.afterPropertiesSet();
return bean.getObject();
}
}
RoomEntityToReservationResponseConverter.java:
public class RoomEntityToReservationResponseConverter implements Converter<RoomEntity, ReservationResponse>{
@Override
public ReservationResponse convert(RoomEntity source) {
ReservationResponse reservationResponse = new ReservationResponse();
reservationResponse.setRoomNumber(source.getRoomNumber());
reservationResponse.setPrice( Integer.valueOf(source.getPrice()) );
Links links = new Links();
Self self = new Self();
self.setRef(ResourceConstants.ROOM_RESERVATION_V1 + "/" + source.getId());
links.setSelf(self);
reservationResponse.setLinks(links);
return reservationResponse;
}
}
Not sure what is going on - I am new to Spring Boot. Looking at similar questions has not helped, because I don't understand the root problem, if someone could spell out the solution using code from this particular instance, that would be helpful to get a better idea.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
