Spring Batch Admin - 无法在字符串值“$ {batch.business.schema.script}”中解析占位符'batch.business.schema.script'

时间:2018-03-28 13:39:16

标签: spring-batch-admin

我将Spring批处理应用程序集成到Spring Batch Admin中 - 我收到以下错误无法在字符串值“$ {batch.business.schema.script}”中解析占位符'batch.business.schema.script'

[org.springframework.web.context.ContextLoaderListener]
 org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'org.springframework.jdbc.datasource.init.DataSourceInitializer#0' defined in null: Could not resolve placeholde'batch.business.schema.script' in string value "${batch.business.schema.script}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'batch.business.schema.script' in string value "${batch.business.schema.script}"
    at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:211)
    at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:223)
    at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:86)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:162)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:988)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1860)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'batch.business.schema.script' in string value "${batch.business.schema.script}"
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
    at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer$PlaceholderResolvingStringValueResolver.resolveStringValue(PropertyPlaceholderConfigurer.java:259)
    at org.springframework.beans.factory.config.BeanDefinitionVisitor.resolveStringValue(BeanDefinitionVisitor.java:282)

1 个答案:

答案 0 :(得分:0)

请参考我的other answer来查看代码结构。

我不再使用Spring Batch管理员但我记得收到这个错误,我这样解决了。

在重写文件 - src\main\resources\META-INF\spring\batch\override\env-context.xml中,我改变了这个,

<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <!--  Below two lines are commented by Sabir-->
                <!--  <value>classpath:/org/springframework/batch/admin/bootstrap/batch.properties</value>-->
                <!-- <value>classpath:batch-default.properties</value> -->
                <value>classpath:batch-${ENVIRONMENT:hsql}.properties</value>
                <value>classpath:application.properties</value>
            </list>
</property>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
        <property name="ignoreResourceNotFound" value="true" />
        <property name="ignoreUnresolvablePlaceholders" value="false" />
        <property name="order" value="1" />
    </bean>

注意这一行 - <value>classpath:batch-${ENVIRONMENT:hsql}.properties</value>

然后我创建了一个文件 - src\main\resources\batch-db2.properties,因为我的db是db2。

batch.job.configuration.package=****You put your java package ****


batch.drop.script=classpath*:/org/springframework/batch/core/schema-drop-db2.sql
#Not needed in our case since we are already using runId incrementer
#batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.DB2SequenceMaxValueIncrementer
batch.schema.script=classpath:DB2_BATCH_DDL.sql
batch.business.schema.script=classpath:/business-schema-db2.sql

#Copied from batch.properties of spring-batch-admin-manager API project
batch.jdbc.testWhileIdle=false
batch.jdbc.validationQuery=
batch.data.source.init=false
batch.job.configuration.file.dir=target/config
batch.job.service.reaper.interval=60000

batch.files.upload-dir=/sba/input

注意密钥 - batch.business.schema.script,根据您的数据库和数据,将该文件放在那里,并带有一些虚拟的SELECT SQL值。架构。

基本上,概念是Spring Batch管理员假定某些属性值&amp;这些值应该被你覆盖。