设为首页 收藏本站
查看: 629|回复: 0

[经验分享] Maven 找不到oracle jdbc 驱动,谁之过?

[复制链接]

尚未签到

发表于 2016-7-27 08:45:03 | 显示全部楼层 |阅读模式
  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

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-249958-1-1.html 上篇帖子: 在 RHEL3 上配置 Oracle 10g Data Guard 下篇帖子: Oracle的JDBC驱动的版本你了解吗--转载
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表