你可以创建一个 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 中你需要添加repository 标签
<repositories>
<repository>
<id>remote</id>
<url>Url where you have hosted the jar</url>
</repository>
</repositories>
另外,如果您的遥控器受密码保护,您需要添加 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 和 version