繁体   English   中英

在Spring Shell中运行date命令(“无法运行程序……系统找不到指定的文件”)

[英]Run the date command in Spring Shell (“Cannot run program … the system cannot find the file specified”)

根据说明的文件

OsCommands-此命令的关键字是感叹号,在感叹号之后,您可以传入要执行的Unix / windows命令字符串

这意味着,我们可以通过在OS Shell中添加!前缀来执行OS Shell中的OS命令! (感叹)。

但是我相信这里有些问题,或者我缺少一些东西。 当我尝试时,出现以下错误。

hw-shell>! date
command is: date
Unable to execute command date [Cannot run program "date" (in directory "."): CreateProcess error=2, The system cannot find the file specified]

我认为您可能忘记了在Spring Shell类中设置类路径,使用下面的行设置类路径,然后尝试...

new ClassPathXmlApplicationContext("classpath*:/META-INF/spring/spring-shell-plugin.xml");

有关更多参考: http : //docs.spring.io/spring-shell/docs/current/reference/html/shell.html

根据异常消息的缺失,您是否在Windows的%PATH%环境中真正拥有了“日期”命令。

“日期”是Windows命令外壳程序的内置命令。 似乎这些内置命令在spring-shell中不可用,并且spring-shell会照看在Windows路径中以文件形式实际存在的命令。

可以使用非内置的Windows命令,例如calc( ! calc )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM