[英]How to invoke a JAR resides in the maven local repository?
As part of a CI/CD process, I'm pulling a JAR from a maven repository (Sonatype nexus)作为 CI/CD 过程的一部分,我正在从 maven 存储库(Sonatype nexus)中提取 JAR
Now, I'd like to simply "java -jar" it.现在,我想简单地“java -jar”它。
What is the simplest way to do it?最简单的方法是什么?
Should I just use the command java -jar ${MAVEN_HOME}/repository/com/company/path/to/my/x.jar
?我应该只使用命令
java -jar ${MAVEN_HOME}/repository/com/company/path/to/my/x.jar
吗?
Or is there a simpler way?或者有没有更简单的方法?
You can create a sh file and this to download 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 "$@"
The Next step will help you to download jar to another project
下一步将帮助您将 jar 下载到另一个项目
In your pom.xml you need to add repository
tag在你的 pom.xml 你需要添加
repository
标签
<repositories>
<repository>
<id>remote</id>
<url>Url where you have hosted the jar</url>
</repository>
</repositories>
Also, you need to add setting.xml if your remote is password protected此外,如果您的遥控器受密码保护,您需要添加 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>
After that add dependency in your pom.xml, it will download the jar to you local m2 folder之后在您的 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>
This groupId
, artifactId
and version
that you need to add when you will create the jar创建 jar 时需要添加的此
groupId
、 artifactId
和version
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.