gpt4 book ai didi

java - 如何通过execute shell向Jenkins作业中的JAR传递参数

转载 作者:行者123 更新时间:2023-11-30 06:36:35 26 4
gpt4 key购买 nike

  1. 我需要在入口点类之一中包含主类吗?
  2. 我尝试添加主类,但是当我尝试传递其主类无法加载或找不到时。

这是我使用的命令:

jar -xvf jarname.jar 
java -cp /path/filename.class $JOB_URL $USER $PASSWORD

路径名是入口点所在的文件名,并且具有 main() 方法。

最佳答案

1) Do I need to have main class in one of entry point class?

是的。并且传递参数不需要解压缩 jar 存档:请参阅“How do I pass parameters to a jar file at the time of execution?

java -jar jarname.jar  param1 param2

但这需要 MANIFEST file inside the jar which reference the main class

Main-Class: MyPackage.MyClass

或者您可以使用 -he 'jar e' 选项(如果您的 jar 没有 Manifest.txt 文件):

If the entrypoint class name is in a package it may use a '.' (dot) character as the delimiter.
For example, if Main.class is in a package called foo the entry point can be specified in the following ways:

jar cfe Main.jar foo.Main foo/Main.class

在这两种情况下,您都不必解压 jar。

关于java - 如何通过execute shell向Jenkins作业中的JAR传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45121759/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com