Configuration Spring批处理源目录[target/config]不存在

Configuration Spring批处理源目录[target/config]不存在,configuration,spring-batch,spring-batch-admin,Configuration,Spring Batch,Spring Batch Admin,我有一个spring批处理应用程序,它的属性文件batch-default.properties设置为 batch.job.configuration.file.dir=target/config 现在,此应用程序在我的本地计算机上运行良好,即使我没有任何此类目录,但当我尝试在我的集成服务器上部署相同的目录时,我收到错误: Cannot resolve reference to bean 'org.springframework.integration.config.SourcePollingC

我有一个spring批处理应用程序,它的属性文件batch-default.properties设置为

batch.job.configuration.file.dir=target/config

现在,此应用程序在我的本地计算机上运行良好,即使我没有任何此类目录,但当我尝试在我的集成服务器上部署相同的目录时,我收到错误:

Cannot resolve reference to bean 'org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean#0.source' while setting bean property 'source'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean#0.source': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Source directory [target/config] does not exist.
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:334)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1417)
有没有人遇到过类似的问题

这里有任何帮助


-Vaibhav

我们的测试服务器上也有类似的问题。看起来文件权限有问题,即Spring Batch Admin尝试为“target/config”创建目录结构,但不允许用户创建目录

这是导致问题的链条:

META-INF/spring/batch/bootstrap/integration/configuration context.xml
包含引用属性的文件轮询器的定义:

<file:inbound-channel-adapter directory="${batch.job.configuration.file.dir}" channel="job-configuration-files"
        filename-pattern=".*\.xml">
        <poller max-messages-per-poll="1" cron="5/1 * * * * *" />
    </file:inbound-channel-adapter>
java.io.File.mkdirs()的javadoc说明:

public boolean mkdirs()

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.

Returns:
    true if and only if the directory was created, along with all necessary parent directories; false otherwise
所以发生的是,mkdirs()返回“false”,因为他无法创建目录。以下exists()还将返回“false”,返回原始帖子中所述的错误消息


您可以通过使用绝对路径将参数设置为现有的可写目录,如“/tmp”。不幸的是,如果将作业定义存储在类路径上,我不知道spring批处理特性应该如何工作;如果不使用文件轮询器,而是使用“类路径感知”文件轮询器,则更有意义…

我尝试将batch.job.configuration.file.dir设置为本地计算机上的某个目录,甚至设置为类路径中的目录结构,但没有帮助
 <xsd:attribute name="auto-create-directory" type="xsd:string" default="true">
                <xsd:annotation>
                    <xsd:documentation>
                        Specify whether to automatically create the source directory if it does not yet exist when this
                        adapter is being initialized. The default value is 'true'. If set to 'false' and the directory
                        does not exist upon initialization, an Exception will be thrown.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:attribute>
if (!this.directory.exists() && this.autoCreateDirectory) {
            this.directory.mkdirs();
        }
        Assert.isTrue(this.directory.exists(),
                "Source directory [" + directory + "] does not exist.");
public boolean mkdirs()

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.

Returns:
    true if and only if the directory was created, along with all necessary parent directories; false otherwise