【发布时间】:2020-06-02 13:38:17
【问题描述】:
当我运行我的应用程序时,会显示以下错误:
org.springframework.beans.factory.BeanCreationException:创建名为“pamdaBatchConfigurer”的bean时出错:调用init方法失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建 com.orange.pamda.config.PamdaBatchConfigurer 中定义的名称为“getJobRepository”的 bean 时出错:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.batch.core.repository.JobRepository]:涉及包含 bean 'pamdaBatchConfigurer' 的循环引用 - 考虑将工厂方法声明为静态以独立于其包含实例.工厂方法“getJobRepository”抛出异常;嵌套异常是 java.lang.IllegalArgumentException: DatabaseType not found for product name: [MariaDB] 在 org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:137) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) 在 org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 在 org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) 在 org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) 在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) 在 org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443) 在 org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325) 在 org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) 在 org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4685) 在 org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 在 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) 在 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) 在 java.util.concurrent.FutureTask.run(FutureTask.java:266) 在 org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) 在 java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) 在 org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) 在 org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 在 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) 在 org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) 在 java.util.concurrent.FutureTask.run(FutureTask.java:266) 在 org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) 在 java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) 在 org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) 在 org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 在 org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 在 org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) 在 org.apache.catalina.startup.Catalina.start(Catalina.java:633) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343) 在 org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
这是我的文件“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);
}
}
}
}
我真的不知道这个错误是从哪里来的,有人可以帮帮我吗?
【问题讨论】:
标签: spring hibernate spring-boot spring-mvc