方式1:
basedir 常量 代表 POM文件所在工程的文件夹地址
dependency 本地JAR包
适用环境:自己没有搭建MAVEN仓库服务器,或者 将JAR包传入到服务器,无法下载的情况
在POM.XML中加入
<dependency>
<groupId>com.gxhs.analysis2</groupId> <!-随便写->
<artifactId>netty-client-distributed</artifactId> <!-随便写->
<version>2.0</version> <!-随便写->
<scope>system</scope> <!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它-->
<systemPath>${basedir}/lib/netty-client-distributed-2.0.jar</systemPath> <!--项目根目录下的lib文件夹下-->
</dependency>
方式2:将JAR包传入到MAVEN仓库服务器的 第3方仓库中
1. 可以通过 http://ip:8081/nexus 管理页面 上传到服务器
2. 通过命令行 上传JAR包
mvn install:install-file -DgroupId=org.jboss.cache -DartifactId=jbosscache-core -Dversion=3.2.7.GA -Dpackaging=jar -Dfile=D:\jbosscache-core-3.2.7.GA.jar
一些参数说明如下:
-DgroupId=远程仓库对应的DgroupId
-DartifactId= 远程仓库对应的 DartifactId
-Dversion=对应版本号
一些参数说明如下:
-DgroupId=远程仓库对应的DgroupId
-DartifactId= 远程仓库对应的 DartifactId
-Dversion=对应版本号
在POM.XML中直接引入
<dependency>
<groupId>com.gxhs.analysis2</groupId>
<artifactId>netty-client-distributed</artifactId>
<version>2.0</version>
</dependency>
方式3: 编译时指定外部lib
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>${project.basedir}/src/main/webapp/WEB-INF/lib</extdirs><!--指定外部lib-->
</compilerArguments>
</configuration>
</plugin>