java - Maven 自定义原型发布到存储库
问题描述
我创建了一个自定义的 Maven 原型。现在我想将它推送到一个私有存储库,以便其他项目成员也可以使用它。同时我需要在 eclipse/other IDE 中列出这个。您能否告知如何实现这一目标。非常感谢任何帮助。
解决方案
您可以使用以下 pom 文件作为参考来构建您的 jar 文件并将其分发到内部存储库。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.project</groupId>
<artifactId>myJar</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<tbx.localrepository.ext>http://artifacts.project.net/artifactory/myProject</tbx.localrepository.ext>
</properties>
<distributionManagement>
<repository>
<id>com.localrepository.ext</id>
<name>Intranet Maven Repository for Extensions</name>
<url>${com.localrepository.ext}</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>com.localrepository.ext</id>
<name>Intranet Maven Repository for Extensions</name>
<url>${com.localrepository.ext}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
</repositories>
<dependencies>
<!--//add dependencies-->
</dependencies>
<build>
<!-- Final jar name-->
<finalName>myJar</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
</plugin>
</plugins>
</build>
</project>
当有人需要使用 jar 文件时,可以在pom.xml
该特定项目的文件中指定,其详细信息与以下相同。
<dependency>
<groupId>com.project</groupId>
<artifactId>myJar</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
推荐阅读
- python-3.x - 如何在文本小部件中制作一个输出整数的按钮
- c# - C# - 等待进程退出并关闭“ShowDialog()”
- node.js - 如何在 node js 中将 app.post 和 app.get 合二为一
- sql-server - 我如何从列现有值的表中获取数据
- mongodb - 如何将相同的文档存储在多个集合中
- pyautogui - 使用 pyautogui 时应用程序如何获得鼠标移动
- php - laravel 基于 API 响应调用的自定义认证
- ms-word - 是否有 dart 包来解码 ms word 文档并在颤振应用程序中进行编辑?
- mysql - 在 Codeigniter 中使用查询生成器 - 如何正确别名?
- google-cloud-platform - 使用 Google Cloud Datastore GQL 编辑器时,我可以在 GQL 中使用注释吗?