简体   繁体   中英

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>

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