简体   繁体   English

将Java库添加到Maven

[英]Add java libraries into Maven

I would like to know if there is any way to embed native java libraries in maven as dependency or something like that but from the internet not from local. 我想知道是否有任何方法可以将本地java库作为依赖项或类似方式嵌入到maven中,但可以通过Internet而不是本地进行。

Like java.util or all that jdk provides. 类似于java.util或jdk提供的所有内容。

Example of "pom.xml": “ pom.xml”的示例:

<dependency>
    <groupId>jdk</groupId>
    <artifactId>java.util.arraylist</artifactId>
    <version>1.1.3</version>
</dependency>

All of the standard, built-in Java classes are available to your build already - you don't need to add them as dependencies. 所有标准的内置Java类都已可用于您的构建-您无需将它们添加为依赖项。

If you have a jar (possibly home-built) that you need to use in your maven build as a dependency, you can add it to your local maven repository as an artefact and have your pom.xml depend upon it as normal. 如果您有一个jar(可能是自建的)需要在maven构建中用作依赖项,则可以将其作为人工制品添加到本地maven存储库中,并让pom.xml像往常一样依赖它。

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

For more details, see this SO answer , or this Maven reference for details on how to perform this. 有关更多详细信息,请参见此SO解答或有关如何执行此操作的Maven参考

Think of Maven as an infrastructure that handles dependencies. 将Maven视为处理依赖关系的基础架构。

mvn install

Write to local Maven directory on your machine. 写入计算机上的本地Maven目录。

mvn deploy

Write to an external repository server, eg Nexus, so it can be shared with others. 写入外部存储库服务器(例如Nexus),以便可以与其他服务器共享。 (Your local Maven must be configured to recognize this Nexus.) (您的本地Maven必须配置为可以识别此Nexus。)

See https://maven.apache.org/run.html 参见https://maven.apache.org/run.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM