未找到产品名称的数据库类型:[Informix 动态服务器]
Posted
技术标签:
【中文标题】未找到产品名称的数据库类型:[Informix 动态服务器]【英文标题】:DatabaseType not found for product name: [Informix Dynamic Server] 【发布时间】:2021-11-09 11:35:24 【问题描述】:运行应用程序时出现错误。
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-09-14 14:14:42.689 ERROR 2144 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchConfigurer' defined in class path resource [org/springframework/boot/autoconfigure/batch/BatchConfigurerConfiguration$JdbcBatchConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Unable to initialize Spring Batch
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) ~[spring-beans-5.3.9.jar:5.3.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) ~[spring-beans-5.3.9.jar:5.3.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.9.jar:5.3.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.9.jar:5.3.9]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.9.jar:5.3.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.9.jar:5.3.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.9.jar:5.3.9]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.9.jar:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) [spring-boot-2.5.4.jar:2.5.4]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) [spring-boot-2.5.4.jar:2.5.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) [spring-boot-2.5.4.jar:2.5.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) [spring-boot-2.5.4.jar:2.5.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) [spring-boot-2.5.4.jar:2.5.4]
at com.mybat.MybatApplication.main(MybatApplication.java:10) [classes/:na]
Caused by: java.lang.IllegalStateException: Unable to initialize Spring Batch
at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.initialize(BasicBatchConfigurer.java:106) ~[spring-boot-autoconfigure-2.5.4.jar:2.5.4]
at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.afterPropertiesSet(BasicBatchConfigurer.java:95) ~[spring-boot-autoconfigure-2.5.4.jar:2.5.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1845) ~[spring-beans-5.3.9.jar:5.3.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782) ~[spring-beans-5.3.9.jar:5.3.9]
... 15 common frames omitted
Caused by: java.lang.IllegalArgumentException: DatabaseType not found for product name: [Informix Dynamic Server]
at org.springframework.batch.support.DatabaseType.fromProductName(DatabaseType.java:84) ~[spring-batch-infrastructure-4.3.3.jar:4.3.3]
at org.springframework.batch.support.DatabaseType.fromMetaData(DatabaseType.java:123) ~[spring-batch-infrastructure-4.3.3.jar:4.3.3]
at org.springframework.batch.core.repository.support.JobRepositoryFactoryBean.afterPropertiesSet(JobRepositoryFactoryBean.java:183) ~[spring-batch-core-4.3.3.jar:4.3.3]
at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.createJobRepository(BasicBatchConfigurer.java:133) ~[spring-boot-autoconfigure-2.5.4.jar:2.5.4]
at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.initialize(BasicBatchConfigurer.java:101) ~[spring-boot-autoconfigure-2.5.4.jar:2.5.4]
... 18 common frames omitted
我的申请文件
package com.mybat;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MybatApplication
public static void main(String[] args)
SpringApplication.run(MybatApplication.class, args);
mybatchConfig 文件
package com.mybat.config;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.batch.MyBatisCursorItemReader;
import org.mybatis.spring.batch.builder.MyBatisCursorItemReaderBuilder;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.file.FlatFileItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.FileSystemResource;
import com.mybat.model.Product;
import com.mybat.writer.ConsoleItemWriter;
@Configuration
@EnableBatchProcessing
public class BatchConfig
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(BatchConfig.class);
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Autowired
private SqlSessionFactory fbaSqlSessionFactory;
@Bean
public DataSource fbaDatasource()
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName("com.informix.jdbc.IfxDriver");
ds.setUrl("xyz");
ds.setUsername("user");
ds.setPassword("user2");
return ds;
@Bean
public SqlSessionFactory fbaSqlSessionFactory() throws Exception
SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
sqlSessionFactory.setDataSource(fbaDatasource());
return sqlSessionFactory.getObject();
@Bean(name="autoReplnshOrdsReader", destroyMethod="")
public ItemReader<Product> createAutoReplnshOrdsReader()
MyBatisCursorItemReader<Product> reader = new MyBatisCursorItemReader<>();
Map<String, Object> parameterValues = new HashMap<>();
parameterValues.put("clientId1", "1");
reader.setSqlSessionFactory(fbaSqlSessionFactory);
if (false)
logger.info("Getting single size::[] orders from replenishment_param table", "S");
parameterValues.put("selectedSize", "S");
reader.setQueryId("getSingleSizeReplnshParamOrds");
else
logger.info("Getting all orders from replenishment_param table");
reader.setQueryId("getAllReplnshParamOrds");
reader.setParameterValues(parameterValues);
return reader;
@Bean(name="autoReplnshOrdsProcessor")
public ItemProcessor<Product, Product> createAutoReplnshOrdsProcessor()
return Product ->
return Product;
;
@Bean(name="autoReplnshOrdsWriter")
public ItemWriter<Product> createAutoReplnshOrdsWriter() throws IOException
FlatFileItemWriter<Product> flatFileItemWriter = new FlatFileItemWriter<>();
flatFileItemWriter.setName("createWeeklyReportFlatFileWriter");
flatFileItemWriter.setEncoding("UTF-8");
String customerOutputPath = File.createTempFile("customerOutput",
".out").getAbsolutePath();
System.out.println(">> Output Path: " + customerOutputPath);
flatFileItemWriter.setResource(new FileSystemResource(customerOutputPath));
flatFileItemWriter.setLineAggregator(new CustomerLineAggregator());
return flatFileItemWriter;
// Step1
@Bean
public Step autoReplnshOrdsStep(@Qualifier("autoReplnshOrdsReader") ItemReader<Product>
autoReplnshOrdsReader,
@Qualifier("autoReplnshOrdsProcessor") ItemProcessor<Product, Product>
autoReplnshOrdsProcessor,
@Qualifier("autoReplnshOrdsWriter") ItemWriter<Product> autoReplnshOrdsWriter)
return stepBuilderFactory.get("autoReplnshOrdsStep")
.<Product, Product> chunk(10)
.reader(autoReplnshOrdsReader)
.processor(autoReplnshOrdsProcessor)
.writer(autoReplnshOrdsWriter)
.build();
@Bean
public Job fbaAutoReplenishmentBatchJob(
@Qualifier("autoReplnshOrdsStep") Step autoReplnshOrdsStep)
return jobBuilderFactory.get("fbaAutoReplenishmentBatchJob")
.preventRestart()
.incrementer(new RunIdIncrementer())
.start(autoReplnshOrdsStep)
.build();
lineaggregator 代码
package com.mybat.config;
import org.springframework.batch.item.file.transform.LineAggregator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mybat.model.Product;
public class CustomerLineAggregator implements LineAggregator<Product>
private ObjectMapper objectMapper = new ObjectMapper();
@Override
public String aggregate(Product item)
try
return objectMapper.writeValueAsString(item);
catch (JsonProcessingException e)
throw new RuntimeException("Unable to serialize Customer", e);
模型文件代码
package com.mybat.model;
import java.io.Serializable;
import org.springframework.stereotype.Component;
@Component
public class Product implements Serializable
private String un_no;
private String prt_ord_no;
private String prt_ord_dt;
private String ord_sts_cd;
private String prt_div_no;
private String prt_prc_lis_src_no;
private String prt_no;
private String prt_ds;
private String ord_ln_sts_cd;
private String ord_ln_shp_dt;
private String prt_shp_mtd_cd;
private String ord_ln_no;
private String sh_qt;
private String car_cd;
private String shp_trck;
private String act_ord_ln_no;
public String getUn_no()
return un_no;
public void setUn_no(String un_no)
this.un_no = un_no;
public String getPrt_ord_no()
return prt_ord_no;
public void setPrt_ord_no(String prt_ord_no)
this.prt_ord_no = prt_ord_no;
public String getPrt_ord_dt()
return prt_ord_dt;
public void setPrt_ord_dt(String prt_ord_dt)
this.prt_ord_dt = prt_ord_dt;
public String getOrd_sts_cd()
return ord_sts_cd;
public void setOrd_sts_cd(String ord_sts_cd)
this.ord_sts_cd = ord_sts_cd;
public String getPrt_div_no()
return prt_div_no;
public void setPrt_div_no(String prt_div_no)
this.prt_div_no = prt_div_no;
public String getPrt_prc_lis_src_no()
return prt_prc_lis_src_no;
public void setPrt_prc_lis_src_no(String prt_prc_lis_src_no)
this.prt_prc_lis_src_no = prt_prc_lis_src_no;
public String getPrt_no()
return prt_no;
public void setPrt_no(String prt_no)
this.prt_no = prt_no;
public String getPrt_ds()
return prt_ds;
public void setPrt_ds(String prt_ds)
this.prt_ds = prt_ds;
public String getOrd_ln_sts_cd()
return ord_ln_sts_cd;
public void setOrd_ln_sts_cd(String ord_ln_sts_cd)
this.ord_ln_sts_cd = ord_ln_sts_cd;
public String getOrd_ln_shp_dt()
return ord_ln_shp_dt;
public void setOrd_ln_shp_dt(String ord_ln_shp_dt)
this.ord_ln_shp_dt = ord_ln_shp_dt;
public String getPrt_shp_mtd_cd()
return prt_shp_mtd_cd;
public void setPrt_shp_mtd_cd(String prt_shp_mtd_cd)
this.prt_shp_mtd_cd = prt_shp_mtd_cd;
public String getOrd_ln_no()
return ord_ln_no;
public void setOrd_ln_no(String ord_ln_no)
this.ord_ln_no = ord_ln_no;
public String getSh_qt()
return sh_qt;
public void setSh_qt(String sh_qt)
this.sh_qt = sh_qt;
public String getCar_cd()
return car_cd;
public void setCar_cd(String car_cd)
this.car_cd = car_cd;
public String getShp_trck()
return shp_trck;
public void setShp_trck(String shp_trck)
this.shp_trck = shp_trck;
public String getAct_ord_ln_no()
return act_ord_ln_no;
public void setAct_ord_ln_no(String act_ord_ln_no)
this.act_ord_ln_no = act_ord_ln_no;
@Override
public String toString()
return "Status" +
"un_no=" + un_no +
", prt_ord_no='" + prt_ord_no + '\'' +
", prt_ord_dt='" + prt_ord_dt + '\'' +
", prt_ord_dt='" + prt_ord_dt + '\'' +
", ord_sts_cd='" + ord_sts_cd + '\'' +
", prt_div_no='" + prt_div_no + '\'' +
", prt_prc_lis_src_no='" + prt_prc_lis_src_no + '\'' +
", prt_no='" + prt_no + '\'' +
", prt_ds='" + prt_ds + '\'' +
", ord_ln_sts_cd='" + ord_ln_sts_cd + '\'' +
", ord_ln_shp_dt='" + ord_ln_shp_dt + '\'' +
", prt_shp_mtd_cd='" + prt_shp_mtd_cd + '\'' +
", ord_ln_no='" + ord_ln_no + '\'' +
", sh_qt='" + sh_qt + '\'' +
", car_cd='" + car_cd + '\'' +
", shp_trck='" + shp_trck + '\'' +
", act_ord_ln_no=" + act_ord_ln_no +
'';
谁能告诉我如何摆脱这个错误,我尝试了很多但无法传递错误,我是 Spring Batch 的新手,如果你能发布工作代码,那将是很大的帮助,因为我我在 *** 中看到了其他解决方案,但由于信息不完整,它们没有帮助。
【问题讨论】:
这能回答你的问题吗? Spring batch --- DatabaseType not found for product name: [Informix Dynamic Server] 【参考方案1】:Spring Batch 不支持Informix
。
这是支持的数据库列表:
public enum DatabaseType
DERBY("Apache Derby"),
DB2("DB2"),
DB2VSE("DB2VSE"),
DB2ZOS("DB2ZOS"),
DB2AS400("DB2AS400"),
HSQL("HSQL Database Engine"),
SQLSERVER("Microsoft SQL Server"),
mysql("MySQL"),
ORACLE("Oracle"),
POSTGRES("PostgreSQL"),
SYBASE("Sybase"),
H2("H2"),
SQLITE("SQLite");
【讨论】:
那么,我该怎么做,如何使用 Informix。你有使用 springbatch 和 informix 的示例代码吗?因为我有任务需要从 informix 获取数据并将其写入文件。以上是关于未找到产品名称的数据库类型:[Informix 动态服务器]的主要内容,如果未能解决你的问题,请参考以下文章