zoukankan      html  css  js  c++  java
  • Maven添加本地Jar包

    手动添加Jar包到我们的Maven项目中。

    1、首先我在项目根目录中创建一个lib文件夹,将jar包拷贝到lib文件夹下

     

    2、然后我们在maven的pom.xml中配置

    <groupId>org.wltea.analyzer</groupId>  
    <artifactId>IKAnalyzer</artifactId>  
    <version>2012FF_u1</version>  
    <scope>system</scope>  
    <systemPath>${project.basedir}/lib/IKAnalyzer2012FF_u1.jar  
    </systemPath>  
     
    eg.我在本地添加的源码
      
          <!-- npl本地so -->
            <dependency>
                <groupId>com.netease.npl</groupId>
                <artifactId>npl</artifactId>
                <version>0.0.1</version>
                <scope>system</scope>
                <systemPath>${project.basedir}/lib/QASystem.jar
            </systemPath>
            </dependency>
            <dependency>
                <groupId>edu.stanford.nlp</groupId>
                <artifactId>nlp</artifactId>
                <version>3.5.2</version>
                <scope>system</scope>
                <systemPath>${project.basedir}/lib/stanford-segmenter-3.5.2.jar
            </systemPath>
            </dependency>

    3、这里的groupId和artifactId以及version都是可以随便填写的 ,scope必须填写为system,而systemPath我们现在我们jar包的地址就可以了

    4、最后我们必须在maven打包的过程中加入我们这个jar包。因为项目运行的时候需要这个Jar,并且我们得拷贝在WEB-INF/lib目录下

    <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>false</filtering>  
                <includes>  
                    <include>**/*.jar</include>  
                </includes>  
            </resource>  
        </webResources>  
    </configuration>  
    <version>2.1.1</version> 
    eg 我在本地添加的源码
                <!-- 加载本地jar包 -->
                <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>false</filtering>
                                <includes>
                                    <include>**/*.jar</include>
                                </includes>
                            </resource>
                        </webResources>
                    </configuration>
                    <version>2.1.1</version>
  • 相关阅读:
    等值首尾和2012年12月27日
    求质数2012年12月29日
    动态规划之最长公共子序列2012年12月22日,23日
    两数组最短距离2012年12月26日
    支配值数目2012年12月25日
    等值数目2012年12月26日
    最长平台问题(递归算法)2012年12月25日
    最长平台问题2012年12月24日
    筛法求质数2012年12月30日
    线性筛法2013年1月2日
  • 原文地址:https://www.cnblogs.com/Weagle/p/5358480.html
Copyright © 2011-2022 走看看