因为安装的文件目录名包含空格,所以找不到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"