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

产品名称找不到数据库类型:[Informix动态服务器]

贺华容
2023-03-14

运行应用程序时,我发现以下错误。

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();
        }
    
}

线聚合器代码

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的新手,如果你能发布工作代码,那将非常有帮助,因为我在stackoverflow中看到了其他解决方案,但由于信息不完整,这些解决方案没有帮助。

共有1个答案

从劲
2023-03-14

Spring批处理不支持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");
}
 类似资料:
  • 我想用Spring boot实现Spring批处理,因为我们使用的是informix数据库,所以当我的Spring boot应用程序启动时,我遇到了以下异常。 配置: 例外 原因:java。lang.IllegalArgumentException:在组织中找不到产品名称:[Informix动态服务器]的DatabaseType。springframework。一批支持数据库类型。位于org的fr

  • 在尝试设置Spring Boot-Spring批处理项目时,我遇到了一个错误,说明: 完整堆栈跟踪如下: 我的属性设置如下: 你知道为什么会这样吗?

  • 在尝试设置Spring Boot-Spring批处理项目时,我遇到了一个错误,说明: 我已经检查了spring batch支持的数据库,但Tibero不在列表中。 有没有其他方法可以让Tibero DB。。。 请参阅以下错误日志。

  • 原因:java.lang.IllegalArgumentException:未找到产品名称[Informix Dynamic Server]的DatabaseType.FromProductName(DatabaseType.java:79)的Org.SpringFramework.Botch.Support.DatabaseType.FromMetadata(DatabaseType.java:

  • 在Visual Studio 2015专业版中打开我的项目时,我的所有视图(*. cshtml)中都有以下错误(以及更多)。 错误CS0246找不到类型或命名空间名称“系统”(您是否缺少使用指令或程序集引用?)严重性代码描述项目文件行 错误CS0518预定义类型“系统”。对象“”未定义或导入严重性代码描述项目文件行 错误CS0518预定义类型“系统”。字符串“”未定义或导入 我有这些参考资料: 我

  • 我已经创建了空的ASP.NET核心项目,我想在那里设置角。为此,我需要应用程序服务静态文件。所以我的startup.cs看起来是: 怎么了?