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>
  • 相关阅读:
    VS 2010下一次性配置opencv(32位和64位相同)
    模拟鼠标事件
    Main函数参数argc,argv说明
    Visual Studio 2010 LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏解决方案
    常量指针和指针常量
    strlen函数实现的几种方法
    杀死指定的进程名
    typedef和typename关键字
    如何理解dart的mixin
    c# 通过dllimport 调用c 动态链接库
  • 原文地址:https://www.cnblogs.com/Weagle/p/5358480.html
Copyright © 2011-2022 走看看