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>
复制代码

转载于:https://www.cnblogs.com/Jeely/p/11301154.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值