英文:
How to make my dependency available to other developers?
问题
我最近在Maven中创建了自己的API,并且需要将依赖项提供给其他人使用。我尝试在另一个项目中使用这个依赖项,但它找不到它。我需要做什么才能将它发布出去?
我的依赖项:
<dependency>
<groupId>org.dec4234</groupId>
<artifactId>JavaDestinyAPI</artifactId>
<version>1.0</version>
</dependency>
在GitHub上可用。
英文:
I recently created my own API in maven, and I need to make the dependency available to others. I have tried using the dependency in another project, but it can't find it. What do I need to do in order to publish it?
My dependency:
<dependency>
<groupId>org.dec4234</groupId>
<artifactId>JavaDestinyAPI</artifactId>
<version>1.0</version>
</dependency>
Available on GitHub
答案1
得分: 1
你需要将你的库上传到Maven存储库。默认情况下,每个Maven项目都使用Maven Central存储库,其中包含大多数常见的公共可用库的副本,你可能习惯了只需在你的pom.xml
的<dependencies>
部分中添加一个条目。
这是一个上传库到Maven Central的指南 - https://central.sonatype.org/pages/ossrh-guide.html。我之前亲自使用过它,虽然需要一些工作,但这可能是你最好的选择。
你也可以托管自己的Maven存储库,但我将详细说明这一路线留给其他人的回答。
英文:
You need to upload your library to a Maven repository. By default, every Maven project uses the Maven Central repository - which contains copies of most common publicly available libraries that you are probably used to using by just putting an entry in the <dependencies>
section of your pom.xml
.
Here is a guide to uploading a library to Maven Central - https://central.sonatype.org/pages/ossrh-guide.html. I've personally used it previously and whilst it does take some work, its probably your best option.
You can also host your own Maven repository, but I'll leave detailing that route to someone else's answer.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论