当前位置: 首页 > 知识库问答 >
问题:

如何修正错误“创建名为…的bean时出错”

杨海
2023-03-14

当我运行应用程序时,会显示以下错误:

下面是我的文件“pamdabatchConfigurer.java”:

    package com.orange.pamda.config;

import java.util.Date;
import java.util.Set;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.configuration.annotation.BatchConfigurer;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.explore.support.JobExplorerFactoryBean;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;

import com.orange.pamda.config.batch.listener.SendFileAfterExportListener;
import com.orange.pamda.worker.config.CatalogueExporterJobConfiguration;
import com.orange.pamda.worker.config.CatalogueImporterJobConfiguration;
import com.orange.pamda.worker.config.CommonJobConfiguration;
import com.orange.pamda.worker.config.DataExporterJobConfiguration;
import com.orange.pamda.worker.config.HierarchyValidatorJobConfiguration;
import com.orange.pamda.worker.config.JobBuilderFactory;
import com.orange.pamda.worker.config.KoalaExporterJobConfiguration;
import com.orange.pamda.worker.config.MappingExporterJobConfiguration;
import com.orange.pamda.worker.config.MappingImporterJobConfiguration;
import com.orange.pamda.worker.config.OrphanExporterJobConfiguration;
import com.orange.pamda.worker.config.ReleaseJobConfiguration;
import com.orange.pamda.worker.config.SummaryExporterJobConfiguration;

@Configuration
@EnableBatchProcessing(modular = true)
@Import({ CommonJobConfiguration.class, CatalogueExporterJobConfiguration.class,
        CatalogueImporterJobConfiguration.class, DataExporterJobConfiguration.class,
        HierarchyValidatorJobConfiguration.class, KoalaExporterJobConfiguration.class,
        MappingExporterJobConfiguration.class, MappingImporterJobConfiguration.class,
        OrphanExporterJobConfiguration.class, ReleaseJobConfiguration.class, SummaryExporterJobConfiguration.class })
public class PamdaBatchConfigurer implements BatchConfigurer {

    @Autowired
    private PlatformTransactionManager transactionManager;

    @Autowired
    private DataSource dataSource;

    @Override
    @Bean
    public JobRepository getJobRepository() throws Exception {
        JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
        jobRepositoryFactoryBean.setDataSource(dataSource);
        jobRepositoryFactoryBean.setTransactionManager(transactionManager);
        jobRepositoryFactoryBean.setIsolationLevelForCreate("ISOLATION_DEFAULT");
        jobRepositoryFactoryBean.afterPropertiesSet();
        return jobRepositoryFactoryBean.getObject();
    }

    @Override
    public PlatformTransactionManager getTransactionManager() throws Exception {
        return transactionManager;
    }

    @Override
    @Bean
    public JobLauncher getJobLauncher() throws Exception {
        SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
        jobLauncher.setJobRepository(getJobRepository());
        // jobLauncher.setTaskExecutor(getTaskExecutor());
        jobLauncher.afterPropertiesSet();
        return jobLauncher;
    }

    @Override
    @Bean
    public JobExplorer getJobExplorer() throws Exception {
        JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
        jobExplorerFactoryBean.setDataSource(dataSource);
        jobExplorerFactoryBean.afterPropertiesSet();
        return jobExplorerFactoryBean.getObject();
    }

    // @Bean
    // public TaskExecutor getTaskExecutor() {
    // SimpleAsyncTaskExecutor simpleAsyncTaskExecutor = new
    // SimpleAsyncTaskExecutor();
    // simpleAsyncTaskExecutor.setConcurrencyLimit(1000); // no throttle
    // return simpleAsyncTaskExecutor;
    // }

    @Bean
    public JobBuilderFactory getJobBuilderFactory() throws Exception {
        return new JobBuilderFactory(getJobRepository(), sendFileAfterExportListener());
    }

    @Bean
    public StepBuilderFactory getStepBuilderFactory() throws Exception {
        return new StepBuilderFactory(getJobRepository(), transactionManager);
    }

    @Bean
    public SendFileAfterExportListener sendFileAfterExportListener() {
        return new SendFileAfterExportListener();
    }

    @PostConstruct
    @Transactional
    public void init() throws Exception {
        JobExplorer jobExplorer = getJobExplorer();
        JobRepository jobRepository = getJobRepository();
        for (String jobName : jobExplorer.getJobNames()) {
            Set<JobExecution> runningJobExecutions = jobExplorer.findRunningJobExecutions(jobName);
            for (JobExecution runningJobExecution : runningJobExecutions) {
                runningJobExecution.setExitStatus(ExitStatus.UNKNOWN);
                runningJobExecution.setEndTime(new Date());
                jobRepository.update(runningJobExecution);
            }
        }
    }


}

我真的不知道这个错误是从哪里来的,有人能帮我一下吗?

共有1个答案

乐健
2023-03-14

StackTrace最重要的部分:未找到产品名称[MariaDB]的数据库类型

查看此处:https://github.com/spring-projects/spring-framework/issues/22344

类似问题:

 类似资料:
  • 我有一个实体类InAppNotification。看起来像这样的java: 我使用JPA来处理数据库查询,这就是JPA接口的定义: 这是我application.properties的样子: 但是,当我试图在构建后通过运行 来打包应用程序时,我会遇到以下问题: 尝试调用不存在的方法。尝试从以下位置进行:javax.el.ELManager.getExpress sionWorks(ELManage

  • 在将project从Spring Boot版本从1.2.3.release迁移到1.3.0.release之后,我已经开始得到以下异常。 创建类路径资源[org/springframework/boot/autoconfigure/admin/springapplicationadminjmxautoconfiguration.class]中定义的名为'Spring ApplicationAdmi

  • 我遵循本教程将消息发送到azure服务队列:https://docs.microsoft.com/en-us/azure/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-service-bus 到我现有的spring boot应用程序,但我得到以下错误: 用户类别: 控制器类: pom xml: 添加它

  • 我试图将弹性搜索集成到spring-boot应用程序中,但我得到了这个*创建名为“client”的bean时出错*异常,不确定是什么地方出了问题,因为我之前找不到任何类似的线索...非常感谢你为大家指路。这是mu elasticsearch配置: 这是我的主要应用程序: 我的pom.xml: 这是te异常跟踪:

  • 我有这些错误编译,我不知道我哪里错了,我只有这3个类

  • 我正在尝试在spring boot应用程序中使用SQLite。但是应用程序不能创建下面的bean。 org.springframework.boot.autocigure.orm.jpa.hibernatejaconfiguration 我该怎么办?我在这个站点上搜索了相关的问题,但是找不到一个合适的。 如下所示。 4.0.0 org.springframework.Boot spring-boo