Maven 找不到oracle jdbc 驱动,谁之过?

Maven 找不到oracle jdbc  驱动,谁之过?

发表于 2010-03-17

整理于 2012-04-03

整理自source: http://stackoverflow.com/questions/1074869/find-jdbc-driver-in-maven-repository

问: 我想把oracle的jdbc驱动加入到我的项目中(运行时),比如ojdbc14。

我的POM文件如下,


<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
</dependency>

不过这显然是无效的,因为 oracle 的jdbc driver不在Maven的central repository中。

我的两个问题是:

1) 我如何找到一个包含此 artifact 的repository?

2)  我如何添加,maven才能使用?

答:

1), 不幸的是由于二进制许可 binary license的限制, 没有任何一个公共的repository可以包含oracle 的jdbc driver。我们的很多依赖都面对同样的问题,这不是Maven的错。即使你偶然发现了某个公共的repository可以包含这个JAR,那么那一定是违法的。

2),由于二进制许可 binary license的限制,一些 JAR不能加入到 Maven Central repo 中,比如:

Oracle JDBC driver classes for use with JDK1.4的POM 如下:

http://repo2.maven.org/maven2/com/oracle/ojdbc14/10.2.0.3.0/ojdbc14-10.2.0.3.0.pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
<name>Oracle JDBC Driver</name>
<description>Oracle JDBC driver classes for use with JDK1.4</description>
<url>
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
</url>
<licenses>
<license>
<name>
Oracle Technology Network Development and Distribution License Terms
</name>
<url>
http://www.oracle.com/technology/software/htdocs/distlic.html
</url>
</license>
</licenses>
<organization>
<name>Oracle Corporation</name>
<url>http://www.oracle.com</url>
</organization>
</project>
 

因此, 下载这个POM, 打开它, 你就可以找到下载 JAR的URL。下载之后, 你就可以用下面的maven命令添加到你本地的repository 中。也许你需要修改ojdbc.jar 路径。

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 \
     -Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc.jar

 如果你的开发团队有自己的私服, 可参照这个指南( this guide http://maven.apache.org/guides/mini/guide-central-repository-upload.html)上传JAR。

主要原文见下:

Q:

I want to add the oracle jdbc driver to my project as dependency (runtime scope) - ojdbc14. In MVN repository site the dependency to put in the POM is:


<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
</dependency>

of course this does't work as it is not in the central repository used by maven. 2 questions:

1) How do I find a repository (if any) that contains this artifact?

2) How do I add it so that Maven will use it?

Thanks!

A:

1) How do I find a repository (if any) that contains this artifact?

Unfortunately due the binary license there is no public repository with the Oracle Driver JAR. This happens with many dependencies but is not Maven's fault. If you happen to find a public repository containing the JAR you can be sure that is illegal.

2) How do I add it so that Maven will use it?

Some JARs that can't be added due to license reasons have a pom entry in the Maven Central repo . Just check it out, it contains the URL to download the file which in this case is http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html . Once you've downloaded the JAR just add it to your computer repository with:

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 \
     -Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc.jar

If your team has a local Maven repository this guide might be helpful to upload the JAR there

猜你喜欢

转载自palmer.iteye.com/blog/617612