Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring批处理管理,无法替换占位符';batch.business.schema.script';_Java_Spring_Spring Batch_Spring Batch Admin - Fatal编程技术网

Java Spring批处理管理,无法替换占位符';batch.business.schema.script';

Java Spring批处理管理,无法替换占位符';batch.business.schema.script';,java,spring,spring-batch,spring-batch-admin,Java,Spring,Spring Batch,Spring Batch Admin,正在尝试将Spring批处理管理员添加到现有Spring批处理项目 我已经用SpringBatch管理资源和SpringBatch管理器更新了web.xml 我的设置: 在src/main/resources/ 我已经添加了2个属性文件。1是批次默认属性,为空文件,另一个是batch-sqlserver.properties,其内容如下: batch.jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver batch.jdbc.ur

正在尝试将Spring批处理管理员添加到现有Spring批处理项目

我已经用SpringBatch管理资源和SpringBatch管理器更新了web.xml

我的设置:

src/main/resources/

我已经添加了2个属性文件。1是批次默认属性,为空文件,另一个是batch-sqlserver.properties,其内容如下:

batch.jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver    batch.jdbc.url=jdbc:sqlserver://xxx.xxx.xxx:1433;DatabaseName=SpringBatch
batch.jdbc.user=user
batch.jdbc.password=password
batch.jdbc.testWhileIdle=false
batch.jdbc.validationQuery=
batch.drop.script=/org/springframework/batch/core/schema-drop-sqlserver.sql
batch.schema.script=/org/springframework/batch/core/schema-sqlserver.sql
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.SqlServerMaxValueIncrementer
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
batch.business.schema.script=business-schema-sqlserver.sql
batch.database.incrementer.parent=columnIncrementerParent
batch.grid.size=2
batch.jdbc.pool.size=6
batch.verify.cursor.position=true
batch.isolationlevel=ISOLATION_SERIALIZABLE
batch.table.prefix=BATCH_
batch.data.source.init=false
在webapp/META-INF/spring/batch/override/下,我添加了data-source-context.xml,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

       <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
              <property name="jndiName">
                     <value>java:jboss/datasources/springBatchDB</value>
              </property>
       </bean>
</beans>
我看到batch.business.schema.script来自:

spring批处理管理器/src/main/resources/META-INF/spring/batch/bootstrap/manager/data-source-context.xml

其中还有“${batch.schema.script}”,它是从我的batch-sqlserver.properties加载的,但不是batch.business.schema.script

有人知道原因或有什么建议吗??
谢谢

我也遇到了这个问题。我没有单独的覆盖
数据源context.xml
,但我通过使用名为ENVIRONMENT:

-DENVIRONMENT=postgresql

在您的情况下,它将是:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!--  Use this to set additional properties on beans at run time -->
    <bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <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>

</beans>
-DENVIRONMENT=sqlserver

我的猜测是,spring批处理应用程序使用spring概要文件来选择要使用的数据库类型,并且需要初始标志来种子

作为参考,以下是David Syer关于此的帖子:

对于覆盖上下文的方法,他说:

或者,您也可以使用覆盖XML,只要将其放在 正确位置-从用户指南“添加您自己的版本” 中的SpringXML配置文件的相同bean定义 META-INF/spring/batch/override“(在类路径中,而不是war中 文件META-INF)。在这种情况下,只需重写名为 “数据源”


所以你把文件放错地方了。您需要将其移动到类路径上的目录。

尝试覆盖占位符属性,包括您自己的属性

假设您将属性放在application.properties上,那么它将是:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!--  Use this to set additional properties on beans at run time -->
    <bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <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>

</beans>

classpath:/org/springframework/batch/admin/bootstrap/batch.properties
classpath:batch-default.properties
classpath:batch-${ENVIRONMENT:hsql}.properties
类路径:application.properties