如何使用Maven打包jar并在WEB-INF/lib中包含一些依赖项? [英] How can I package a jar with Maven and include some dependencies in WEB-INF/lib?
本文介绍了如何使用Maven打包jar并在WEB-INF/lib中包含一些依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何用Maven打包jar并在WEB-INF/lib中包含一些依赖项?
How can I package a jar with Maven and include some dependencies in WEB-INF/lib?
我尝试过组装,但是难于实现吗?
I tried with assembly, but cannot be achieved easier?
推荐答案
尝试使用maven-assembly-plugin的jar-with-dependencies功能:
Try using the jar-with-dependencies feature of the maven-assembly-plugin:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
这会将所有依赖项合并到您的jar中.用<scope>provided</scope>
标记不想包含在jar中的依赖项,例如:
This will incorporate all dependencies into your jar. Mark the dependencies that you don't want included in your jar with <scope>provided</scope>
, eg:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.4.4</version>
<scope>provided</scope>
</dependency>
这篇关于如何使用Maven打包jar并在WEB-INF/lib中包含一些依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文