Although rarely, but sometimes you will have 3rd party JARs that you need to put in your local repository for use in your builds, since they don't exist in any public repository like Maven Central. The JARs must be placed in the local repository in the correct place in order for it to be correctly picked up by Apache Maven. To make this easier, and less error prone, we have provide a goal in the maven-install-plugin which should make this relatively painless. To install a JAR in the local repository use the following command:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \ -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
If there's a pom-file as well, you can install it with the following command:
mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path-to-pomfile>
With version 2.5 of the maven-install-plugin it gets even better. If the JAR was built by Apache Maven, it'll contain a pom.xml in a subfolder of the META-INF directory, which will be read by default. In that case, all you need to do is:
mvn install:install-file -Dfile=<path-to-file>
由于oracle商业版权问题,maven不能通过中心资源库直接下载jar包,如果想要使用jar包,需要手动处理。
第一步:将ojdbc6.jar放到任意目录下,例如:D:\download\oracle11g驱动jar包
第二步:(需配置及安装maven,可通过mvn -version验证是否安装)在cmd命令中执行
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.1.0.7.0 -Dpackaging=jar -Dfile=D:\download\ojdbc6.jar
这样就将jdbc驱动安装到maven的本地资源库中,进入maven本地资源库:D:\Maven\localRepository,可以看到已经将ojdbc6.jar打包到本地资源库中。
第三步:在所需要的工程中的pom.xml中添加dependency
<dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.1.0.7.0</version> </dependency>
即完成了maven jar包的部署