可以在不知道 jar 文件名的情况下运行 jar 文件 [英] Can run a jar file without knowing the jar file name
问题描述
谁能告诉我如何在不知道 Jar 全名的情况下使用 java -jar 命令运行 jar 文件,我知道前缀但 jar 文件的版本是动态的,所以我不想更新我的 sh每次部署
Can any one tell how to run a jar file using java -jar command without knowing the Jar's full name, I know the prefix but the version of the jar file is dynamic,so I don't want to update my sh for every deplolyment
#!/bin/bash
PROJECT_HOME=/opt/services/testing-batchp
PROJECT_JAR=batch-1.0.8-SNAPSHOT.jar
[ -f /etc/environment ] && . /etc/environment
nohup java -jar -Dspring.config.location=${PROJECT_HOME}/config/ ${PROJECT_HOME}/${PROJECT_JAR} $1 $2 >/dev/null 2>&1 &
我刚刚修改了变量 PROJECT_JAR="batch*.*-SNAPSHOT.jar" 但它不起作用.这里 jar 的版本将在每次部署中更改.请帮忙
I just modified the variable PROJECT_JAR="batch*.*-SNAPSHOT.jar" but its not working. Here the version of the jar will change in each deployment. Please help
推荐答案
尝试以下方法执行脚本,而无需提及 jar 的发布版本.
Try the below approach for executing script without mentioning the jar's release version.
#!/bin/bash
PROJECT_HOME=/opt/services/testing-batchp
PROJECT_JAR=batch-*.*.jar
[ -f /etc/environment ] && . /etc/environment
nohup java -jar -Dspring.config.location=${PROJECT_HOME}/config/ ${PROJECT_HOME}/${PROJECT_JAR} $1 $2 >/dev/null 2>&1 &
确保部署文件夹中只有一个有效的 jar.
Make sure that only one valid jar is there in the deployment folder.
这篇关于可以在不知道 jar 文件名的情况下运行 jar 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!