簡體   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