如何在maven中指定本地jar的路径

use*_*590 4 java jar maven

我正在使用maven2来构建java项目.当我尝试构建使用时,mvn install 我收到编译错误,说某些包xya.abc.aaa不存在.这个包可以在我自己的jar本地磁盘上找到.这个jar(比如test.jar)是由我创建的.

我怎么能告诉maven使用这个本地jar作为它寻找的包可以在我的本地磁盘上使用?

小智 6

您需要将依赖项安装到本地存储库.

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

Where: <path-to-file>  the path to the file to load
       <group-id>      the group that the file should be registered under
       <artifact-id>   the artifact name for the file
       <version>       the version of the file
       <packaging>     the packaging of the file e.g. jar
Run Code Online (Sandbox Code Playgroud)