简体   繁体   中英

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.

Like java.util or all that jdk provides.

Example of "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.

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.

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.

Think of Maven as an infrastructure that handles dependencies.

mvn install

Write to local Maven directory on your machine.

mvn deploy

Write to an external repository server, eg Nexus, so it can be shared with others. (Your local Maven must be configured to recognize this Nexus.)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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