码迷,mamicode.com
首页 > 编程语言 > 详细

如何让maven 将工程依赖的jar 复制到WEB-INF/lib 目录下

时间:2017-01-08 22:28:23      阅读:332      评论:0      收藏:0      [点我收藏+]

标签:依赖   directory   生命周期   阶段   compile   source   plugins   dir   默认   

1.在默认生命周期的compile阶段执行 maven-dependency-plugin:copy-dependencies命令即可:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>sources</goal>
</goals>
</execution>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>src/main/webapp/WEB-INF/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
2.当依赖jar包发生变更时,应该执行clean生命周期,删除所有旧的jar包;这样才能保证WEB-INF/lib和Maven的依赖管理的Jar包一致。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clean</id>
<phase>pre-clean</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<directory>src/main/webapp/WEB-INF/lib</directory>
</configuration>
</execution>
</executions>
</plugin>

如何让maven 将工程依赖的jar 复制到WEB-INF/lib 目录下

标签:依赖   directory   生命周期   阶段   compile   source   plugins   dir   默认   

原文地址:http://www.cnblogs.com/sandea/p/6262866.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!