Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何调用驻留在maven本地存储库中的JAR?_Java_Maven_Jenkins_Continuous Deployment - Fatal编程技术网

Java 如何调用驻留在maven本地存储库中的JAR?

Java 如何调用驻留在maven本地存储库中的JAR?,java,maven,jenkins,continuous-deployment,Java,Maven,Jenkins,Continuous Deployment,作为CI/CD过程的一部分,我将从maven存储库Sonatype nexus中提取一个JAR 现在,我想简单介绍一下java-jar 最简单的方法是什么 我应该只使用命令java-jar${MAVEN_HOME}/repository/com/company/path/to/my/x.jar吗 或者有更简单的方法吗?您可以创建一个sh文件,然后下载jar wget --user USERNAME --password PASSWORD url of the nexus where the ja

作为CI/CD过程的一部分,我将从maven存储库Sonatype nexus中提取一个JAR

现在,我想简单介绍一下java-jar

最简单的方法是什么

我应该只使用命令java-jar${MAVEN_HOME}/repository/com/company/path/to/my/x.jar吗


或者有更简单的方法吗?

您可以创建一个sh文件,然后下载jar

wget --user USERNAME --password PASSWORD url of the nexus where the jar is uploaded

java -Djava.security.egd=file:/dev/./urandom -jar name of the jar.jar
exec "$@"
下一步将帮助您将jar下载到另一个项目

在pom.xml中,需要添加存储库标记

此外,如果您的遥控器受密码保护,则需要添加setting.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                  http://maven.apache.org/xsd/settings-1.0.0.xsd">
 <servers>
    <server>
      <id>remote</id>
      <username>***</username> //username
      <password>****</password> //password
    </server>
  </servers>
</settings>
在pom.xml中添加依赖项之后,它将把jar下载到本地m2文件夹中

<dependency>
            <groupId>group id of project</groupId> 
            <artifactId>artifact of project</artifactId>    //artifact of your jar
            <version>version of your project</version>
        </dependency>
创建jar时需要添加的groupId、artifactId和版本

<dependency>
            <groupId>group id of project</groupId> 
            <artifactId>artifact of project</artifactId>    //artifact of your jar
            <version>version of your project</version>
        </dependency>