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
使用SimpleCommandLinePropertySource提取属性在Java中不起作用_Java_Spring_Args - Fatal编程技术网

使用SimpleCommandLinePropertySource提取属性在Java中不起作用

使用SimpleCommandLinePropertySource提取属性在Java中不起作用,java,spring,args,Java,Spring,Args,尝试使用SimpleCommandLinePropertySource(arg)提取命令行参数 打印参数时,将打印以下内容: SimpleCommandLinePropertySource {name='commandLineArgs'} 这就是我在eclipse中调用主类的方式 各州 使用选项参数 选项参数必须遵循以下确切语法: --optName[=optValue] 也就是说,选项必须以“-”作为前缀,并且可以指定值,也可以不指定值。如果指定了值,则名称和值必须用等号(=)分隔,不带空

尝试使用SimpleCommandLinePropertySource(arg)提取命令行参数

打印参数时,将打印以下内容:

SimpleCommandLinePropertySource {name='commandLineArgs'}
这就是我在eclipse中调用主类的方式

各州

使用选项参数 选项参数必须遵循以下确切语法:

--optName[=optValue]
也就是说,选项必须以“-”作为前缀,并且可以指定值,也可以不指定值。如果指定了值,则名称和值必须用等号(=)分隔,不带空格。该值可以选择为空字符串

您提供的属性参数为

 -key=value
这不是所需的语法
SimpleCommandLinePropertySource
,因此它会忽略它


以指定的格式提供参数,然后您可以正常检索已解析的属性,即通过。

在参数
arg(s)
中是否缺少
s
?也许您在其他地方定义了一些附加的
arg
 -key=value