Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.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批处理的Unix服务器路径_Java_Spring_Unix_Spring Batch - Fatal编程技术网

Java 无法读取资源属性Spring批处理的Unix服务器路径

Java 无法读取资源属性Spring批处理的Unix服务器路径,java,spring,unix,spring-batch,Java,Spring,Unix,Spring Batch,请帮助配置SPRING批处理中unix位置路径的资源路径。在Windows机器上试用时,效果良好 属性文件中配置的属性。 location=//home/dir/file.txt XML配置: <bean id="diDeactivateReader" class="org.springframework.batch.item.file.FlatFileItemReader"> <property name="resource" valu

请帮助配置SPRING批处理中unix位置路径的资源路径。在Windows机器上试用时,效果良好

属性文件中配置的属性。 location=//home/dir/file.txt

XML配置:

<bean id="diDeactivateReader" class="org.springframework.batch.item.file.FlatFileItemReader">
        <property name="resource"
            value="**file:${location}**" />
        <property name="lineMapper">
            <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
                <property name="lineTokenizer">
                    <bean
                        class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
                        <property name="names" value="${column.names}" />
                        <property name="columns" value="${column.position}" />
                    </bean>
                </property>
                <property name="fieldSetMapper">
                    <bean class="org.test.TestMapper" />
                </property>
            </bean>
        </property>
    </bean>

在它可能使用UrlResource的情况下,有一个关于如何指定文件路径的问题。因为您在linux机器上工作,所以需要连续四次“/”

resource = new UrlResource("file:////home/dir/file.txt");
要了解为什么需要这么多斜杠,请参阅URL:

:/#
如果等级库的路径组件以斜杠字符“/”开头,则 路径被视为绝对路径,等级库路径将替换上下文 路径


因此,第三个“/”指定路径是绝对路径,“/home/dir/file.txt”是路径本身。

它看起来像是在类路径中搜索它。。。
文件:${location}
周围的
*
是什么?为什么文件系统路径以
/
开头?
resource = new UrlResource("file:////home/dir/file.txt");
<scheme>://<authority><path>?<query>#<fragment>