Tengo el siguiente mapper
@Mapper
@Component
public interface PriceEntityMapper {
@Mapping(source="brandId", target="brandId")
@Mapping(source="startDate", target="startDate", qualifiedByName = "timestampToLocalDateTime")
@Mapping(source="endDate", target="endDate", qualifiedByName = "timestampToLocalDateTime")
@Mapping(source="priceList", target="priceList")
@Mapping(source="productId", target="productId")
@Mapping(source="priority", target="priority")
@Mapping(source="price", target="price")
@Mapping(source="curr", target="currency")
Price priceEntityToPrice(PriceEntity priceEntity);
@Named("timestampToLocalDateTime")
default LocalDateTime timestampToLocalDateTime(Timestamp timestamp) {
return timestamp.toLocalDateTime();
}
}
y la siguiente implementacion:
@Service
public class PriceServiceImpl implements PriceService {
private final PriceRepository priceRepository;
private final PriceEntityMapper priceEntityMapper;
@Autowired
public PriceServiceImpl(PriceRepository priceRepository, PriceEntityMapper priceEntityMapper) {
this.priceRepository = priceRepository;
this.priceEntityMapper = priceEntityMapper;
}
@Override
public Price getPrice(LocalDateTime applicationDate, Integer productId, Integer brandId) {
try {
//PriceEntity priceEntity = priceRepository.findByBrandIdAndProductIdAndStartDateLessThanEqualApplicationDateAndEndDateGreaterThanEqualApplicationDate(brandId, productId, Timestamp.valueOf(applicationDate));
return priceEntityMapper.priceEntityToPrice(new PriceEntity());
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Price not found", e);
}
}
}
Cuando intento levantar la aplicación me dice esto:
Parameter 1 of constructor in com.dharian.application.service.PriceServiceImpl required a bean of type 'com.dharian.infraestructure.mapper.PriceEntityMapper' that could not be found.
No lo entiendo ya que tengo las anotaciones @Mapper and @Component, tambien tengo esto en mi clase main:
@SpringBootApplication
@ComponentScan({"com.dharian.infraestructure","com.dharian.application"})
public class PruebatecnicaApplication {
public static void main(String[] args) {
SpringApplication.run(PruebatecnicaApplication.class, args);
}
}
pero sigue sin encontrar los beans. Por si sirve de algo, uso IntelliJ.
@Mapper(componentModel = "spring")