关于前端:关于execa执行command命令报错-unable-to-access-jarfile-jar

42次阅读

共计 958 个字符,预计需要花费 3 分钟才能阅读完成。

因为装置的文件目录名蕴含空格,所以找不到 jar 包而报错。

看上图可知,当命令中蕴含空格须要本义才能够。

let sourcePath = process.env.NODE_ENV === 'development' ? 'D:\\work\\gateway-desktop\\extraResources' : process.resourcesPath + '\\extraResources'
let commandStart = 'java -jar -Dspring.datasource.primary.jdbc-url=jdbc:sqlite:"' + sourcePath + '\\yinglink-pacs.sqlite" -Dspring.datasource.second.jdbc-url=jdbc:sqlite:"'+ sourcePath +'\\yinglink-pacs.sqlite""' + sourcePath + '\\yinglink-pacs.jar"'
let commandStop = 'wmic process where (commandline LIKE"%%yinglink-pacs%%"and caption="java.exe") call terminate'

execa(commandStart).then(result => {console.log('stop')
    console.log(result.stdout)
})

将每个文件地址用 “” 双引号包裹起来即可,示例如下:

java -jar -Dspring.datasource.primary.jdbc-url=jdbc:sqlite:"D:\\Program Files\\yl-pacs\\resources\\extraResources\\yinglink-pacs.sqlite" -Dspring.datasource.second.jdbc-url=jdbc:sqlite:"D:\\Program Files\\yl-pacs\\resources\\extraResources\\yinglink-pacs.sqlite" "D:\\Program Files\\yl-pacs\\resources\\extraResources\\yinglink-pacs.jar"

正文完
 0