maven引入本地jar
方法一
手动安装:
mvn install:install-file -Dfile=jar包的位置 -DgroupId=pom.xml里的groupId -DartifactId=pom.xml里的artifactId -Dversion=pom.xml里的version -Dpackaging=jar mvn install:install-file -Dfile=D:\mytest\antlr-2.7.2.jar -DgroupId=antlr -DartifactId=antlr -Dversion=2.7.2 -Dpackaging=jar
方法二
指定jar包目录进行引入
<!--Maven引入本地jar--> <dependency> <groupId>antlr</groupId> <artifactId>antlr</artifactId> <version>2.7</version> <!--引用本地jar--> <scope>system</scope> <!--本地jar路径--> <systemPath>${project.basedir}/src/main/lib/antlr-2.7.2.jar</systemPath> </dependency>
- groupId:自定义
- artifactId:自定义
- version:自定义
- scope:必须是system
- systemPath:jar包的路径(idea编写的时候会有提示的)
这种方式打war包时需要配置打包时引入本地jar包:
<!-- 为了将本地jar包打入WEB-INF/lib下而增加的配置--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webResources> <resource> <!-- 指向的是包含所有要用jar包的目录 --> <directory>${basedir}/src/main/lib</directory> <!-- 编译后要把这些jar包复制到的位置 --> <targetPath>WEB-INF/lib</targetPath> </resource> </webResources> </configuration> </plugin>