Не удалось автопровода. Не найдено бобов типа InstructionRepository - PullRequest
0 голосов
/ 26 марта 2019

Попытка создать bean-компонент в приложении SpringBoot, но появляется следующая ошибка: «Не удалось автоматически подключить. Не найдены bean-компоненты типа« InstructionRepository »».

InstructionRepository помечен аннотацией @Repository в банке и является интерфейсом, расширяющим интерфейс данных Spring

ScheduleProcessor - это метод

Когда я пытаюсь добавить аннотацию @ComponentScan, передавая значение базового пакета, ошибка исчезает, НО, при загрузке приложения появляется следующая ошибка

Для параметра 0 конструктора в com.xxx.resync.config.AppConfig требуется компонент типа com.xxx.repo.InstructionRepository, который не может быть найден. Действие: рассмотрите возможность определения bean-компонента типа com.xxx.repo.InstructionRepository в вашей конфигурации.

@Configuration
@EnableAutoConfiguration
//@ComponentScan(basePackages = {"com.xxx.repo"})
public class AppConfig {

    @Value("${pssHttp.connectTimeout:3000}")
    private int connectTimeout;

    @Bean
    public RestTemplate getRestTemplate() {
        RestTemplate restTemplate = new RestTemplate();
        final HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
        factory.setConnectTimeout(connectTimeout);
        factory.setReadTimeout(connectTimeout);
        restTemplate.setRequestFactory(factory);
        return restTemplate;
    }

    @Bean
    public ScheduleUpdater getScheduleUpdater() {
        return new ScheduleUpdater(true);
    }

    @Bean
    public ScheduleProcessor scheduleProcessor(InstructionRepository instructionRepository, ScheduleUpdater scheduleUpdater) {
        return new ScheduleProcessor(instructionRepository, scheduleUpdater);
    }
}

InstructionRepository

@Repository
public interface InstructionRepository extends CouchbaseRepository<Instruction, String> {

}

Как мы можем исправить ошибку и иметь возможность загрузить загрузочное приложение Spring?

Любые предложения приветствуются.

1 Ответ

0 голосов
/ 26 марта 2019

Вам необходимо добавить @EnableCouchbaseRepositories, чтобы включить репо, например, к AppConfig.

...