如何使用Maven打包jar并在WEB-INF / lib中包含一些依赖项?
我尝试过装配,但是不能轻松实现?
答案 0 :(得分:15)
尝试使用maven-assembly-plugin的jar-with-dependencies功能:
<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中的依赖项,例如:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.4.4</version>
<scope>provided</scope>
</dependency>