maven打包其他目录文件到war包

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/limm33/article/details/66969110
项目开发过程中原来是传统的web工程,现在要改成maven的方式进行开发,存在原来很多老的jar包,不过只是临时编译maven项目用到(当然,并不建议这样操作),所以才用了scope为system的方式引入:
<dependency> 
<groupId>com.inspur.bigdata</groupId>  
<artifactId>lousing-framework</artifactId>
<version>7.0.0</version>  
<scope>system</scope>   
<systemPath>${project.basedir}/lib/webharvest.jar</systemPath> 
</dependency>


但是这也存在着一些问题,当我们打包的时候,不能把scope为system的打到war包中,以下为scope作用范围有5种:

    * compile,缺省值,适用于所有阶段,会随着项目一起发布。 
    * provided,类似compile,期望JDK、容器或使用者会提供这个依赖。如servlet.jar。 
    * runtime,只在运行时使用,如JDBC驱动,适用运行和测试阶段。 
    * test,只在测试时使用,用于编译和运行测试代码。不会随项目发布。 
    * system,类似provided,需要显式提供包含依赖的jar,Maven不会在Repository中查找它。 

可以看出除了以上几个scope的值种只有compile是随项目一起发布的,我们解决想把其他的也发布到war包里的方法如下:

 <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${project.basedir}/lib</directory>
<targetPath>WEB-INF/lib</targetPath>
<filtering>true</filtering>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>

猜你喜欢

转载自blog.csdn.net/limm33/article/details/66969110