zoukankan      html  css  js  c++  java
  • Maven如何打包本地依赖包

    有的jar包,在maven中心库里面是没有的,那么,如何在项目中使用呢?

    假设我们需要使用:apache-ant-zip-2.3.jar

    将该jar包,放在项目的lib目录,例如:

    image

    在pom.xml里面增加该jar的引用,例如:

    image

            <dependency>
                <groupId>org.apache</groupId>
                <artifactId>apache-ant-zip</artifactId>
                <version>2.3</version>
                <scope>system</scope> 
                <systemPath>${basedir}/lib/apache-ant-zip-2.3.jar</systemPath>                 
            </dependency>

    这样就可以在项目中使用apache-ant-zip-2.3.jar了!

    这里有个问题,在项目打包成war的时候,如何将apache-ant-zip-2.3.jar包含在内呢?

    其实在pom.xml里面做个配置即可,例如:

    image

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

    当然在include里面,也是可以打包其他的文件的,诸如xml,properties等配置文件。

    打包以后,发现apache-ant-zip-2.3.jar果然已经在war包里面。

    image

    大功告成!

    花间一壶酒,独酌无相亲。 

    举杯邀明月,对影成三人。 

    木头大哥所发的文章均基于自身实践,各位江湖好汉可以通过:hellowood23@163.com 联系之。

  • 相关阅读:
    kernel makefile分析 之include路径分析
    python模块,包,安装
    python 资源
    Python版QQ群发消息
    marvell 88f6282 工程包制作
    CPU : 二级缓存容量
    编译多个文件到内核模块
    展布频谱(Spread Spectrum, SS)
    编程练习 链表题目反序,合并
    汇编语言基础之七 框架指针的省略(FPO)
  • 原文地址:https://www.cnblogs.com/hellowood23/p/5144279.html
Copyright © 2011-2022 走看看