如何在maven中添加jar包

如题所述

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

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

[html] view plain copy
<groupId>org.wltea.analyzer</groupId>
<artifactId>IKAnalyzer</artifactId>
<version>2012FF_u1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/IKAnalyzer2012FF_u1.jar
</systemPath>

3、这里的groupId和artifactId以及version都是可以随便填写的 ,scope必须填写为system,而systemPath我们现在我们jar包的地址就可以了
4、最后我们必须在maven打包的过程中加入我们这个jar包。因为项目运行的时候需要这个Jar,并且我们得拷贝在WEB-INF/lib目录下

[html] view plain copy
<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>
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答
大家正在搜