Maven本地库添加Oracle JDBC驱动

官方Maven Repository里已经再也不支持较新的ojdbc驱动,只能从官网上下载相关jar包,而后手动添加到本地maven数据仓库中。若是是Mysql驱动同理。 ojdbc<version>.jar下载地址:http://www.oracle.com/technetwork/database/features/jdbc/index-091264.htmlhtml

mvn -s D:\mvnrepo\.m2\settings.xml install:install-file "-DgroupId=com.oracle" "-DartifactId=ojdbc6" "-Dversion=11.1.0.7.0" "-Dpackaging=jar" "-Dfile=ojdbc6-11.1.0.7.0.jar"

参数说明:sql

  • install:install-file指定安装文件
  • -s指定的是本地maven库的配置文件,而且指定了本地maven库的地址。不使用这个参数默认安装在家目录的.m2目录中。
  • -packaging指定类型
  • -Dfile指定的是下载的jar包.
  • -DgroupId、-DartifactId、-Dversion指定的是pom文件中依赖参数

pom.xml文件添加依赖示例:apache

<dependencies>  
	<!-- oracle jdbc driver -->    
	<dependency>      
		<groupId>com.oracle</groupId>      
		<artifactId>ojdbc6</artifactId>      
		<version>11.1.0.7.0</version>  
	</dependency>  
</dependencies>

D:\mvnrepo.m2\settings.xml内容oracle

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
			http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<localRepository>D:\mvnrepo\.m2\repository</localRepository>
</settings>
相关文章
相关标签/搜索