在IntelliJ/Maven的Java项目中包含依赖项?

huangapple go评论61阅读模式
英文:

Including dependencies in Java project on Intellij/Maven?

问题

这听起来有些愚蠢,但是否有办法让我为我的Java项目指定依赖,就像在package.json文件中那样,这样,从我的GitHub存储库下载项目代码的其他人就能够在没有任何错误或缺少库的情况下运行它?

我以前从未尝试过使用外部的Java库,比如Apache Commons。我所使用过的最多的是JavaFX,但仅限于个人项目级别。我主要担心的是,如果我将代码推送到存储库并让其他人克隆它,由于导入的库未被下载,代码可能无法正常运行。

是否有类似于package.json的依赖项,让运行代码的人可以自动下载所有依赖库,并在他们的系统上运行它?

英文:

This sounds dumb but is there anyway for me to specify dependencies for my Java project like how I would in a package.json file so that someone else who was to download the project code from my GitHub repo, would be able to run it without any errors or missing libraries?

I have never tried using external Java libraries before, such as apache commons. The most I ever used was JavaFX but on a personal project level. My main concern is that if I were to push my code up to the repo and have someone else clone it. It might not run properly as the imported libraries are not downloaded.

Is there something similar to package.json dependencies where the person who runs the code would automatically download all dependency libraries and have it run on their system?

答案1

得分: 1

你可以使用Maven或者Gradle来实现这个目的。Maven有pom.xml文件,您可以在其中指定所有的依赖。类似地,Gradle有build.gradle文件,起到相同的作用。

英文:

You can use Maven or Gradle for this purpose. Maven has pom.xml where you can specify all your dependencies. Similarly gradle has build.gradle which does the same job.

huangapple
  • 本文由 发表于 2020年8月17日 22:18:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/63452774.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定