Linux 无法解析字符串值文件中的占位符my_propertySource:$-错误仅在Unix中发生

Linux 无法解析字符串值文件中的占位符my_propertySource:$-错误仅在Unix中发生,linux,spring,shell,unix,properties,Linux,Spring,Shell,Unix,Properties,只有在Unix中运行时,我才会出现此错误。我的意思是,使用相同的代码,我可以在Windows中完美运行 Exception in thread "main" java.lang.IllegalArgumentException: Could not resolve placeholder 'CONF_DIR' in string value "file:${CONF_DIR}" at org.springframework.util.PropertyPlaceholderHelp

只有在Unix中运行时,我才会出现此错误。我的意思是,使用相同的代码,我可以在Windows中完美运行

Exception in thread "main" java.lang.IllegalArgumentException: Could not resolve placeholder 'CONF_DIR' in string value "file:${CONF_DIR}"
        at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)

带有文件的PropertySource:$

@Configuration
@ComponentScan("com…
@EnableBatchProcessing
@PropertySource("file:${CONF_DIR}")
public class BatchConfig {

在Windows命令提示符下,它确实可以完美地工作:

C:\20160601>SET CONF_DIR=C:/20160601/config.properties
C:\20160601>java –cp my_executable_jar.jar com/my_company/main
... no error at all since propertySource("file:$... finds the value previously settup
在UNIX z/OS390 shell中,发生上述错误

===> CONF_DIR=/usr/certain_path/config.properties
===> echo $CONF_DIR
/usr/certain_path/config.properties
===> ./java –cp my_executable_jar.jar com/my_company/main
... now, propertySource("file:$ will not find the value previously settup although I checked and it is there (see the echo)
如果我尝试在BatchConfig类中使用straigh

@PropertySource("file:/usr/certain_path/config.properties")
它确实有效。因此,我猜想java命令“file:$”和我在Unix中如何设置变量之间存在一些错误或误解


我仔细阅读了很多关于这两种方法的文章,据我所知,这两种方法都是正确的。我指的是设置shell变量的方式和访问方式。此外,它可以在Windows中工作。

export CONF\u DIR=/usr/specific\u path/config.properties


如果不使用导出,则仅在当前环境中设置。如果导出它,则它将成为一个环境变量,并由子进程继承

请改为试试“export CONF_DIR=/usr/specific_path/config.properties”。谢谢。它解决了我的问题。如果你能提供它作为答案,我将设置为正确答案。如果您能解释一下“CONF_DIR=/usr/specific_path/config.properties”和“export CONF_DIR=/usr/specific_path/config.properties”之间的区别,我将不胜感激。请注意,echo确实显示了相同的内容。