我们使用Maven从中央库或者从本地库等获取所需要的jar文件,但有的项目文件即不在中央库又不在本地库,需要我们手动下载。
外部依赖注入的两种方式:
1. 通过install-file 的形式加入到本地库。 mvn install:install-file -Dfile=c:kaptcha-{version}.jar -DgroupId=com.google.code
-DartifactId=kaptcha -Dversion={version} -Dpackaging=jar
但这种方式,移植到其它地方后,又需要再次加入到另一电脑的本地库。
ojdbc因为牵扯付费因此虽然在mvn上可以看到但是没法下载。
mvn install:install-file -Dfile=D:Repositoryojdbc14-10.2.0.4.0.jar -DartifactId=ojdbc14 -DgroupId=com.oracle -Dversion=10.2.0.4.0 -Dpackaging=jar
2. 项目中外部依赖
在src目录下创建lib文件夹,将jar文件放入其中。
在pom.xml文件中添加以下数据:
<dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<scope>system</scope>
<version>6</version>
<systemPath>${basedir}srclibojdbc-6.jar</systemPath>
</dependency>
保存后,数据会自动进入到Maven Dependency中。