简体   繁体   English

如何使用POM在类路径中添加本地jars文件夹

[英]How to add local jars folder in class path using POM

There are almost 10 local jars (these jars are required to build my application) in my Java application. 我的Java应用程序中几乎有10个本地jar(构建我的应用程序需要这些jar)。 I want them to add to the classpath using POM. 我希望它们使用POM添加到类路径中。 How can I do that? 我怎样才能做到这一点?

You can add the dependency as system scope and refer to it by its full path. 您可以将依赖项添加为系统范围,并通过其完整路径进行引用。 Consider that the JAR is located in /lib. 考虑一下JAR位于/ lib中。 Then add the dependency in your pom.xml file as following: 然后在您的pom.xml文件中添加依赖项,如下所示:

<dependency>
  <groupId>com.abc.pqr</groupId>
  <artifactId>sample-app</artifactId>
  <version>1.0</version>
  <scope>system</scope>
  <systemPath>${basedir}/lib/your_jar.jar</systemPath>
</dependency>

${basedir} represents the directory containing pom.xml. ${basedir}表示包含pom.xml的目录。

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

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