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

Spring批处理管理:无法解析字符串值“${Batch.jdbc.driver}”中的占位符“Batch.jdbc.driver”

夏侯枫
2023-03-14

我试图将spring batch与spring batch Admin集成。但是我得到这个错误无法解析字符串值“${batch.jdbc.driver}”中的占位符“batch.jdbc.driver”请帮忙。谢谢。

enter code hereorg.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in URL [jar:file:/C:/Users/dimakatso.bopape/.gradle/caches/modules-2/files-2.1/org.springframework.batch/spring-batch-admin-manager/2.0.0.BUILD-SNAPSHOT/82b20b57e2c2e2d910d7b2c37bf58c6976071f1/spring-batch-admin-manager-2.0.0.BUILD-SNAPSHOT.jar!/META-INF/spring/batch/bootstrap/manager/data-source-context.xml]: Could not resolve placeholder 'batch.jdbc.driver' in string value "${batch.jdbc.driver}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'batch.jdbc.driver' in string value "${batch.jdbc.driver}"
at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:211)
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:222)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:86)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:166)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
at za.co.momentum.retail.minion.batch.MinionBatchApplication.main(MinionBatchApplication.java:21)

由:java.lang.IllegalArgumentException引起:无法解析字符串值“${batch.jdbc.driver}”中的占位符“batch.jdbc.driver”,位于org.springframework.util.PropertyPlaceHolderHelper.parseStringValue(PropertyPlaceHolderHelper.java:174),位于org.springframework.util.PropertyPlaceHolderHelper.replacePlaceHolder.java:126),位于springframework.beans.factory.config.beandefinitionvisitor.resolveStringValue(BeanDefinitionvisitor.java:282)在org.springframework.beans.factory.config.beanDefinitionvisitor.java:204)在org.springframework.beans.factory.config.beanDefinitionvisitor.visitpropertyValue(BeanDefinitionvisitor.java:204)在ngframework.beans.factory.config.PlaceHolderConfigurerSupport.doProcessProperties(PlaceHolderConfigurerSupport.java:208)...13个常见框架被省略

spring.jpa.hibernate.dialect: org.hibernate.dialect.DB2Dialect
spring.jpa.show-sql: false
spring.jpa.generate-ddl: false

database.minion.url=jdbc:db2://***
database.minion.username=***
database.minion.password=***
database.minion.driver-class-name=com.ibm.db2.jcc.DB2Driver
server.port=8091
-DENVIRONMENT=db2

主类

@ComponentScan(basePackageClasses={ PersistenceConfig.class })
@SpringBootApplication(exclude = {HypermediaAutoConfiguration.class, MultipartAutoConfiguration.class})
@EnableBatchAdmin
public class MinionBatchApplication {

    public static void main(String[] args) {
        SpringApplication.run(MinionBatchApplication.class, args);
    }
}

数据源配置

@Configuration
public class PersistenceConfig {

  @Bean
    @ConfigurationProperties(prefix = "database.minion")
    public DataSource minionDataSource() {
        return DataSourceBuilder
            .create()
            .build();
    }}

共有1个答案

丁雅惠
2023-03-14
 # Placeholders batch.*
#    for MySQL:
batch.jdbc.driver=com.mysql.jdbc.Driver
batch.jdbc.url=jdbc:mysql://localhost:3306/xxxx
batch.jdbc.user=root
batch.jdbc.password=root
batch.jdbc.testWhileIdle=true
batch.jdbc.validationQuery=SELECT 1
batch.schema.script=classpath:/org/springframework/batch/core/schema-mysql.sql
batch.drop.script=classpath*:/org/springframework/batch/core/schema-drop-mysql.sql
batch.business.schema.script=classpath:business-schema-mysql.sql
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer

# Non-platform dependent settings that you might like to change
 batch.data.source.init=false

我想在您的情况下,“驱动程序类”的属性名称是不同的。

 类似资料:
  • 问题内容: 我正在尝试使用文件中的属性,但它似乎不起作用。 这是我的代码: 此类使用批注获取属性。它也被声明为Spring Service并链接到我的文件: 使用,我将此文件链接到我的文件: 这确实有意义,对吗? 但是,当我尝试启动项目时,Tomcat抛出此异常: 或者,简而言之: 编辑: 这是我的web.xml: 我的infraContext.xml被导入到另一个名为applicationCon

  • 正在尝试将Spring Batch Admin添加到现有的Spring Batch项目中。 我已经更新了网页。带有spring batch admin资源和spring batch admin manager的xml 我的设置: 在src/main/resources下/ 我添加了两个属性文件。1是批处理默认属性,它是一个空文件,另一个是批处理sqlserver。包含以下内容的属性: 在webap

  • 问题内容: 我对春天还很陌生,所以请问这是一个愚蠢的问题。当我尝试启动程序时,出现以下错误:。执行以下代码时,将引发错误: 资源文件夹中存在一个名为的属性文件,其中包含主机和端口的信息。我不确定在哪里定义(如果有的话)。也许甚至没有定义,这就是问题所在。我需要将其更改为类似的东西还是缺少其他内容? 问题答案: 您没有正确读取属性文件。propertySource应该将参数传递为:或。将注释更改为:

  • 我有个例外 我也尝试过使用JarLoader和PropertiesLauncher,但运气并不好。 我确实在application.properties中定义了属性sysm.client.api.path,但为了更好地衡量,我还将它作为-d参数-dsysm.client.api.path=my-path添加到命令行中。 注意:IntelliJ没有将其作为a-jar运行;相反,它在一个大型类路径命令

  • 我看到下面的错误,当我试图读取属性从类路径在我的Spring项目中使用的@属性源注释。我已经粘贴了我的代码下面,请你帮助让我知道我错过了什么?谢谢。 警告:在上下文初始化期间遇到异常-取消刷新尝试:org.springframework.beans.factory.BeanCreation异常:创建名称为“客户仓库”的bean时出错:自动构建依赖项注入失败;嵌套异常java.lang.Illega

  • 在DOS中,字符串是一个有序的字符集合,比如:。 编号 字符串操作 描述 1 创建字符串 字符串可以通过以下方式在DOS中创建。 2 空字符串 空的字符串 3 字符串插值 字符串插值是一种通过将常量,变量,文字和表达式中的值包含在字符串文字中来构造新的字符串值的方法。 4 字符串连接 可以使用运算符连接两个字符串,一个字符串和一个字符,或者两个字符。 以下是一个简单的例子,展示了如何使用字符串连接