背景
有时候一些依赖的jar是我们仓库中并没有的,比如自己开发的jar包,华为云适配过程中 华为改过的jar。有两种方式吧jar引入到工程中
1、最简单的将jarupload到私服中,具体百度!
这样就可以很方便的在pom.xml中直接使用<dependency>引用依赖
2、临时加入到工程中
-
1、在工程中,一般在${basedir}下创建一个lib,然后把jar拷贝进来
-
2、将jar手动设置为libary库,因为idea编译需要
如果要删除这些libary包,可使用ctrl + alt + shift +S
-
3、在pom.xml中临时指定这个jar,否则maven编译的时候去仓库那边找不到,有如下两种方式:
1:)使用dependency <dependency> <groupId>com.my.tools</groupId> <!--自定义--> <artifactId>AllJdbc2ES</artifactId> <!--自定义--> <version>1.0</version> <!--自定义--> <scope>system</scope> <!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它--> <systemPath>${basedir}/lib/AllJdbc2ES-1.0.jar</systemPath> <!--项目根目录下的lib文件夹下--> </dependency> 2:)使用maven-compiler-plugin插件,指定lib包 <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> <compilerArguments> <extdirs>${basedir}/lib</extdirs><!--指定外部lib--> </compilerArguments> </configuration> </plugin>
如此即可使用了