Spring Boot не нашел бинJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Spring Boot не нашел бин

Сообщение Anonymous »

У меня есть следующий картограф:

Код: Выделить всё

@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();
}
}
и следующая реализация:

Код: Выделить всё

@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);
}
}
}
Ну, когда я пытаюсь запустить приложение, выдает следующую ошибку:

Параметр 1 конструктора в com.dharian.application.service.PriceServiceImpl потребовался bean-компонент типа com.dharian.infraestructure.mapper.PriceEntityMapper, который не удалось найти.

Но у меня есть аннотации @Mapper и @Component, а также

Код: Выделить всё

@SpringBootApplication
@ComponentScan({"com.dharian.infraestructure", "com.dharian.application"})
public class PruebatecnicaApplication {
public static void main(String[] args) {
SpringApplication.run(PruebatecnicaApplication.class, args);
}
}
Для сканирования посылок. Не работает.
что это может быть?
Я попробовал @ComponentScan, изменил автоподключение и изменил аннотацию через Mapper класс.

Подробнее здесь: https://stackoverflow.com/questions/784 ... und-a-bean
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»