简体   繁体   English

使用Maven从本地将JAR添加到WAR包装

[英]Adding JAR from local to the WAR packing using Maven

I'm having a lib folder inside the maven project. 我在maven项目中有一个lib文件夹。 I'm adding each of the jars to the dependencies like, 我将每个罐子添加到依赖项中,例如,

     <dependency>
          <groupId>abcd</groupId>
          <artifactId>abcd</artifactId>
          <version>1.0</version>
          <scope>system</scope>
          <systemPath>${basedir}/lib/abcd.jar</systemPath>
     </dependency>

When packaging the project to war, these jar are not being bundled inside 'WEB-INF/lib' 在打包用于战争的项目时,这些jar不会捆绑在“ WEB-INF / lib”中

Please someone help me with this. 请有人帮助我。

Here is the description of the scope "system": 这是范围“系统”的描述:

This scope is similar to provided except that you have to provide the JAR which contains it explicitly. 该范围类似于所提供的范围,除了必须提供显式包含它的JAR。 The artifact is always available and is not looked up in a repository. 该工件始终可用,并且不会在存储库中查找。

That means, maven assumes that this dependency is already present in the target system and don't be delivered with your WAR file. 这意味着,maven假定此依赖关系已存在于目标系统中,并且不会随您的WAR文件一起提供。

You can add your libraries to your local repository. 您可以将库添加到本地存储库。

Here an example: 这里是一个例子:

mvn install:install-file -Dfile=<path-to-your-jarfile> -DgroupId=abcd -DartifactId=abcd -Dversion=1.0 -Dpackaging=jar

After doing that you add the dependency with scope "compile": 完成之后,添加范围为“ compile”的依赖项:

<dependency>
      <groupId>abcd</groupId>
      <artifactId>abcd</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
</dependency>

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

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