Нет подходящего компонента типа org.springframework.batch.core.Step - PullRequest
0 голосов
/ 24 апреля 2020
Error:
2020-04-24 00:52:50,892  INFO bcm.BankruptcyCasePurgeDownloadJobProcessingApplication - No active profile set, falling back to default profiles: default
2020-04-24 00:52:53,038  WARN annotation.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.spri
ngframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bankruptcyCasePurgeDownloadJob' defined in class path resource [com/cgi/ec/down
load/bcm/BankruptcyCasePurgeDownloadSetupConfiguration.class]: Unsatisfied dependency expressed through method 'bankruptcyCasePurgeDownloadJob' parameter 1; nested exce
ption is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.batch.core.Step' available: expected at least
1 bean which qualifies as autowire candidate. Dependency annotations: {}
2020-04-24 00:52:53,071  INFO logging.ConditionEvaluationReportLoggingListener -

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

// Java код
@SpringBootApplication @ComponentScan (basePackages = {"com.cgi.e c .download.bcm", "com.cgi.e c .interfaces.util.properties "}) publi c class BankruptcyCasePurgeDownloadJobProcessingApplication {

    private static final XLogger LOG = XLoggerFactory.getXLogger(BankruptcyCasePurgeDownloadJobProcessingApplication.class);

    public static void main(String[] args) throws Exception {
        String arguments = Arrays.toString(args);
        LOG.debug("[main] starting with args: {}", arguments);

        ConfigurableApplicationContext ctx = SpringApplication.run(BankruptcyCasePurgeDownloadJobProcessingApplication.class, args);
        JobLauncher jobLauncher = ctx.getBean(JobLauncher.class);
        System.out.println("Spring boot success");
        Job jobInstance = ctx.getBean("bankruptcyCasePurgeDownloadJob", Job.class);

        jobLauncher.run(jobInstance, InterfacesCommonConfiguration.getJobParameters());
    }
}

@Configuration
@EnableBatchProcessing
public class BankruptcyCasePurgeDownloadSetupConfiguration {
    private static final XLogger LOG = XLoggerFactory.getXLogger(BankruptcyCasePurgeDownloadSetupConfiguration.class);

    private static final String JOB_NAME = "bankruptcyCasePurgeDownload";

    /**
     * Main SpringBatch Job that defines the steps to the batch job
     * 
     * @return SpringBatch Job object
     */
    @Bean
    public Job testStepJob(JobBuilderFactory jobBuilderFactory, Step bankruptcyCasePurgeDownloadStep) {
        LOG.entry();
        return LOG.exit(jobBuilderFactory.get(JOB_NAME + "Job")
                .incrementer(new RunIdIncrementer())
                .flow(testStep)
                .end()
                .build());
    }

1 Ответ

0 голосов
/ 24 апреля 2020

Вы пытаетесь внедрить компонент типа Step здесь:

@Bean
public Job testStepJob(JobBuilderFactory jobBuilderFactory, Step bankruptcyCasePurgeDownloadStep) {
    ...
 }

, но в соответствии с ошибкой ваш контекст приложения не содержит компонент этого типа.

Убедитесь, что вы импортируете класс конфигурации, содержащий определение вашего шагового компонента, или определите компонент такого типа в отсканированных пакетах.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...