首页 > 代码库 > maven如何引入本地依赖

maven如何引入本地依赖

今天遇到一个问题,要做一个语音识别接口的对接,想先跑一下对方给的demo,但是发现使用了maven却没有在pom里添加依赖,不知道他那边是怎么运行的。于是想到要在pom中添加本地依赖,结果真的可以:


System Dependencies

Dependencies with the scope system are always available and are not looked up in repository. They are usually used to tell Maven about dependencies which are provided by the JDK or the VM. Thus, system dependencies are especially useful for resolving dependencies on artifacts which are now provided by the JDK, but where available as separate downloads earlier. Typical example are the JDBC standard extensions or the Java Authentication and Authorization Service (JAAS).

A simple example would be:

<project>
...
<dependencies>
<dependency>
<groupId>javax.sql</groupId>
<artifactId>jdbc-stdext</artifactId>
<version>2.0</version>
<scope>system</scope>
<systemPath>${java.home}/lib/rt.jar</systemPath>
</dependency>
</dependencies>
...
</project>
If your artifact is provided by the JDK‘s tools.jar the system path would be defined as follows:

<project>
...
<dependencies>
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>tools</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
...
</project>

ok,so easy!