Adding JAR from local to the WAR packing using Maven

I'm having a lib folder inside the maven project. 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'

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. 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.

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":

<dependency>
      <groupId>abcd</groupId>
      <artifactId>abcd</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
</dependency>
链接地址: http://www.djcxy.com/p/74664.html

上一篇: Maven的

下一篇: 使用Maven将JAR从本地添加到WAR包装