在 Maven 存储库中查找 Oracle JDBC 驱动程序
我想将 oracle jdbc 驱动程序作为依赖项(运行时范围)添加到我的项目中 - ojdbc14。 在 MVNrepository 站点中,放入 POM 中的依赖项是:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
</dependency>
当然这不起作用,因为它不在 maven 使用的中央存储库中。 2 个问题:
如何找到包含此工件的存储库(如果有)?
如何添加它以便 Maven 能够使用它?
I want to add the oracle jdbc driver to my project as dependency (runtime scope) - ojdbc14.
In MVNrepository 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:
How do I find a repository (if any) that contains this artifact?
How do I add it so that Maven will use it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(22)
这对我来说就像魅力一样。 我经历了多种方法,但这对我有所帮助。
确保遵循每个步骤并将 XML 文件命名为完全相同。
https: //blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides
这个过程有点乏味,但确实有效。
This worked for me like charm. I went through multiple ways but then this helped me.
Make sure you follow each step and name the XML files exactly same.
https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides
The process is a little tedious but yes it does work.
对于依赖
尝试
For dependency
Try
已解决
需要启用此存储库才能查找 Oracle 10.0.3.0 依赖项(此设置需要在 Buildconfig.groovy 中完成
grails.project.dependency.resolver = "ivy" // 或 ivy
还可以使用以下编译时设置 Oracle 驱动程序下载
运行时 "com.oracle:ojdbc:10.2.0.3.0"
这应该可以解决找不到 Oracle 驱动程序的问题用于 Grails 应用程序
SOLVED
This repository needs to be enable for finding Oracle 10.0.3.0 dependecies (this setting needs to be done in Buildconfig.groovy
grails.project.dependency.resolver = "ivy" // or ivy
Also use following setting for compile time Oracle driver download
runtime "com.oracle:ojdbc:10.2.0.3.0"
This should solve your issue for not finding the Oracle driver for grails application
如何找到包含此工件的存储库(如果有)?
不幸的是,由于二进制许可证,没有包含 Oracle 驱动程序 JAR 的公共存储库。 许多依赖项都会发生这种情况,但这不是 Maven 的错。 如果您碰巧发现包含该 JAR 的公共存储库,您可以确定这是非法的。
如何添加它以便 Maven 能够使用它?
一些由于许可证原因而无法添加的 JAR 在 Maven 中央存储库。 只需检查一下,它包含供应商的首选 Maven 信息:
...以及下载文件的 URL,在本例中为
http://www.oracle.com/technology/software/tech /java/sqlj_jdbc/index.html。
下载 JAR 后,只需将其添加到您的计算机存储库(请注意,我从 POM 中提取了 groupId、artifactId 和版本):
用于生成 POM 的最后一个参数将使您免受 pom.xml 警告
如果您的团队有本地 Maven 存储库本指南 上传 JAR 可能会有所帮助。
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.
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 vendor's preferred Maven info:
...and 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 (note I pulled the groupId, artifactId and version from the POM):
The last parameter for generating a POM will save you from pom.xml warnings
If your team has a local Maven repository this guide might be helpful to upload the JAR there.
Oracle JDBC 驱动程序现已在 Oracle Maven 存储库(不在 Central)中提供。
Oracle Maven 存储库需要用户注册。 说明可以在以下位置找到:
https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides
更新 2019-10- 03
我注意到 Spring Boot 现在使用 Maven Central 的 Oracle JDBC 驱动程序。
对于 Gradle 用户,请使用:
无需用户注册。
更新 2020-03-02
Oracle 现在在 com.oracle.database 组 ID 下发布驱动程序。 有关更多信息,请参阅 Anthony Accioly 的回答。 谢谢安东尼。
与 JDK6、JDK7 和 JDK8 兼容的 Oracle JDBC 驱动
程序 与 JDK8、JDK9 和 JDK11
兼容的 Oracle JDBC 驱动程序 与 JDK10 和 JDK11 兼容的 Oracle JDBC 驱动程序
The Oracle JDBC Driver is now available in the Oracle Maven Repository (not in Central).
The Oracle Maven Repository requires a user registration. Instructions can be found in:
https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides
Update 2019-10-03
I noticed Spring Boot is now using the Oracle JDBC Driver from Maven Central.
For Gradle users, use:
There is no need for user registration.
Update 2020-03-02
Oracle is now publishing the drivers under the com.oracle.database group id. See Anthony Accioly answer for more information. Thanks Anthony.
Oracle JDBC Driver compatible with JDK6, JDK7, and JDK8
Oracle JDBC Driver compatible with JDK8, JDK9, and JDK11
Oracle JDBC Driver compatible with JDK10 and JDK11
无论出于何种原因,我都无法使上述任何解决方案发挥作用。 (仍然不能。)
我所做的是将 jar 包含在我的项目中(blech),然后为其创建一个“系统”依赖项来指示 jar 的路径。 这可能不是正确的方法,但它确实有效。 并且它消除了团队中其他开发人员(或设置构建服务器的人员)将 jar 放入本地存储库的需要。
更新:当我运行 Hibernate Tools 时,此解决方案适用于我。 然而,它似乎不适用于构建 WAR 文件。 它不包括目标 WAR 文件中的 ojdbc6.jar 文件。
1)在项目的根目录中创建一个名为“lib”的目录。
2) 将 ojdbc6.jar 文件复制到那里(无论该 jar 的名称是什么。)
3) 创建一个如下所示的依赖项:
丑陋,但对我有用。
要将文件包含在 war 文件中,请将以下内容添加到您的 pom 中
For whatever reason, I could not get any of the above solutions to work. (Still can't.)
What I did instead was to include the jar in my project (blech) and then create a "system" dependency for it that indicates the path to the jar. It's probably not the RIGHT way to do it, but it does work. And it eliminates the need for the other developers on the team (or the guy setting up the build server) to put the jar in their local repositories.
UPDATE: This solution works for me when I run Hibernate Tools. It does NOT appear to work for building the WAR file, however. It doesn't include the ojdbc6.jar file in the target WAR file.
1) Create a directory called "lib" in the root of your project.
2) Copy the ojdbc6.jar file there (whatever the jar is called.)
3) Create a dependency that looks something like this:
Ugly, but works for me.
To include the files in the war file add the following to your pom
下载 jar 并将其放入项目
src/lib
中。 现在您可以使用 Maven 安装程序插件了。现在您只需执行一次
mvn clean
,oracle lib就会安装在您的本地maven存储库中。Download the jar and place it in your project
src/lib
. Now you can use the maven installer plugin.Now you only have to execute
mvn clean
once and the oracle lib is installed in your local maven repository.Oracle 现在在 maven.oracle.com 上公开了一个 Maven 存储库
但是您需要经过身份验证。
参阅 https://blogs.oracle.com/WebLogicServer/entry/weblogic_server_and_the_oracle
请 博客文章中的评论 ojdbc 驱动程序应该在以下坐标处可用:
Oracle is now exposing a maven repository at maven.oracle.com
However you need to be authenticated.
See https://blogs.oracle.com/WebLogicServer/entry/weblogic_server_and_the_oracle
According to the comments in the blog post the ojdbc driver should be available at the following coordinates:
尝试使用:
Try with:
1. 如何找到包含此工件的存储库(如果有)?
由于 DavidS 已评论我在回答时引用的行不再存在于当前(在我现在正在写)我链接的 OTN 许可协议。 仅针对旧版本的工件考虑此答案,例如 10.2.0.3.0 等。
所有 Oracle 数据库 JDBC 驱动程序 在 OTN 许可协议。
如果您阅读 OTN 许可协议,您会发现以下许可条款:
这就是为什么你无法在任何公共 Maven 存储库中找到驱动程序的 jar,因为它将单独分发,如果发生这种情况,将违反许可证。
添加依赖项:(
或任何更高版本)使 Maven 仅下载
ojdbc14-10.2.0.3.0.pom
,并且在该 pom 中您可以阅读:它会通知您有关 OTN 许可证的信息。
2.如何添加它以便Maven使用它?
为了使上述依赖项起作用,我同意victor Hugo,他建议你此处手动将 jar 安装到本地 Maven 存储库中(
. m2
目录)通过运行:但我想补充一点,上面的许可条款不仅限制了您无法找到 JDBC jar 的位置,还限制了您安装它的位置!
事实上,你的本地 Maven 存储库必须是私有的,而不是共享的,因为如果它是共享的,那么它将是一种单独分发 jar 的发行版,即使是一小群人进入你的本地区域网络,这代表了违反 OTN 许可协议。
此外,我认为您应该避免在公司存储库管理器中安装 JDBC jar(例如 Artifactory 或 Nexus) 作为单个工件,因为如果安装了它,它将仍然单独分发,即使仅分发给组织中的人员,这表示违反了 OTN 许可协议。
1. How do I find a repository (if any) that contains this artifact?
As DavidS has commented the line I quoted at the time I answered is no longer present in the current (at the time I'm writing now) OTN License Agreement agreement I linked. Consider this answer only for older version of the artifact, as the 10.2.0.3.0 and the like.
All Oracle Database JDBC Drivers are distribuited under the OTN License Agreement.
If you read the OTN License Agreement you find this license term:
so that's why you can't find the driver's jar in any public Maven Repository, because it would be distributed alone, and if it happened it would be a license violation.
Adding the dependency:
(or any later version) make Maven downloads the
ojdbc14-10.2.0.3.0.pom
only, and in that pom you can read:which informs you about the OTN License.
2. How do I add it so that Maven will use it?
In order to make the above dependency works I agree with victor hugo who were suggesting you here to manually install the jar into your local Maven repository (the
.m2
directory) by running:but I want to add that the license term above doesn't limit only where you can't find the JDBC jar, but it limits where you install it too!
In fact your local Maven repository must be private and not shared because if it was shared it would be a kind of distribution in which the jar is distributed alone, even if to a little group of people into your local area network, and this represent a OTN License Agreement violation.
Moreover I think you should avoid installing the JDBC jar in your corporation repository manager (such as Artifactory or Nexus) as a single artifact because if it was installed it would be still distributed alone, even if to people in your organization only, and this represents a OTN License Agreement violation.
您可以使用 Nexus 管理第 3 方依赖项以及标准 Maven 存储库中的依赖项。
You can use Nexus to manage 3rd party dependencies as well as dependencies in standard maven repositories.
截至今天(2020 年 2 月 27 日)Oracle 宣布已在 Maven Central 组 id com.oracle.database:
示例:
As of today (27, February 2020) Oracle announced that it has published all JDBC client libraries from version 11.2.0.4 (e.g. ojdbc6) to 19.3.0 (e.g. ojdbc10) on Maven Central under the group id com.oracle.database:
Example:
到目前为止,还无法使用 Maven 存储库。 我使用 ivy 作为依赖管理工具,但也使用 maven2 的 ibiblio 存储库。 这适用于 ivy:
Maven2 的依赖关系可能是这样的:
注意我定义了 http:// /download.java.net/maven/2/ 和 http://mirrors.ibiblio.org/pub/mirrors/maven/mule/dependency/maven2/[organization]/[module]/[revision]/[artifact]-[revision].[ext] 为我的 ivy 设置上的外部 maven2 存储库。
Up to now, its not possible to use maven repositories. I'm using ivy as dependency management tool, but also use maven2' s ibiblio repositories. And this is working for ivy:
Maven2' s dependency could be something like that:
Notice that i define http://download.java.net/maven/2/ and http://mirrors.ibiblio.org/pub/mirrors/maven/mule/dependencies/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext] as external maven2 repos on my ivy settings.
Oracle JDBC 驱动程序现在可以在Maven Central中使用。
链接如下:
Oracle JDBC 驱动程序 - Maven Central
Oracle 开发人员文章宣布推出Maven Central 中的 Oracle JDBC 驱动程序:
Oracle 宣布 - Oracle JDBC 驱动程序在 Maven Central 中可用
示例:
The Oracle JDBC drivers are now available in Maven Central.
Here is the Link:
Oracle JDBC Drivers - Maven Central
Oracle developers article announcing the availability of the Oracle JDBC drivers in Maven Central:
Oracle announcing - Oracle JDBC drivers available in Maven Central
Example:
大家好消息! 最后我们可以使用Oracle的官方repo:
https: //blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides
Good news everyone! Finally we can use Oracle's official repo:
https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides
就我而言,在添加以下版本依赖项(10.2.0.4)后,它对我有用。 添加此版本 10.2.0.3.0 后,由于 .jar 文件在存储库路径中不可用,因此它不起作用。
In my case it works for me after adding this below version dependency(10.2.0.4). After adding this version 10.2.0.3.0 it doesn't work due to .jar file not avail in repository path.
我在 LGPLv2 下发布开源代码,甚至在与 Oracle 进行多次电子邮件对话后,他们仍不清楚我是否可以在我的发行版中发布他们的二进制 JDBC 驱动程序。 该问题与我的许可证是否与他们的 OTN 条款兼容有关,因此他们建议不允许我运送驱动程序。 大概与这部分有关
因此,即使您设法在您的专有/本地 Maven 存储库中合法发布驱动程序,仍然是对您可以使用该工件进行的操作的限制。 即使我以二进制形式连同完整的 OTN 许可证文件一起提供他们的驱动程序,我仍然无法使用它,并且必须强制我的用户手动下载 Oracle 驱动程序并放入我的库路径,然后才能使用我的软件,这似乎很荒谬。
I ship opensource under LGPLv2 and even after several email conversations with Oracle they were unclear whether I was allowed to ship their binary JDBC driver with my distribution. The issue related to whether my license was compatible with their OTN terms so they suggested I was not permitted to ship the driver. Presumably related to this part
So even if you manage to publish the driver legally in your exclusive/local maven repository there is still the restriction on what you are permitted to do with that artifact. Seems absurd that even if I ship their driver in binary form along with the full OTN license file I still can't use it and must force my users to manually download the Oracle driver and drop into my library path before they can use my software.
您可以在 此处<找到在 Maven 项目上使用 Oracle JDBC 驱动程序的 Github 简单示例项目/a>.
您可以找到持续集成的所有说明 + 示例并在 Travis-CI 上运行。
DEMO
pom.xml
mvnsettings .xml
如何在本地环境中使用
通过 Oracle 登录名在 test/mvnsettings.xml 文件
更改
${OTN_PASSWORD} 中更改
通过 test/mvnsettings.xml 文件中的 Oracle 密码${OTN_USERNAME}
You can find a Github simple sample project for use a Oracle JDBC Driver on Maven Project here.
You can find all explication for your continous integration + a sample and run on Travis-CI.
DEMO
pom.xml
mvnsettings.xml
How to use on local environment
change
${OTN_USERNAME}
by your Oracle login in test/mvnsettings.xml filechange
${OTN_PASSWORD}
by your Oracle password in test/mvnsettings.xml file简化的黑客 - 为我工作
第 1 步:
将您的依赖项更改为
第 2 步:
从以下位置下载 Jar:
OJDBC7
第 3 步:
将jar复制到以下路径
.m2\repository\com\oracle\ojdbc7\12.1.0.2\
第 4 步:
重新运行您的 Maven 构建
Simplified hack - Worked for me
Step 1:
Change your dependency to
Step 2:
Download the Jar from
OJDBC7
Step 3:
Copy the jar into the below path
.m2\repository\com\oracle\ojdbc7\12.1.0.2\
Step 4:
Re-run your maven build
有一个 repo 提供了该 jar。 在 SBT 中添加一个与此类似的解析器:
“oracle 驱动程序存储库”位于“http://dist.codehaus.org/mule/dependency/maven2< /a>”
和依赖项:
"oracle" % "ojdbc14" % "10.2.0.2"
你可以用maven做同样的事情。 pom.xml 和 jar 可用(http://dist.xml 和 jar ) codehaus.org/mule/dependencies/maven2/oracle/ojdbc14/10.2.0.2/)。
There is one repo that provides the jar. In SBT add a resolver similar to this:
"oracle driver repo" at "http://dist.codehaus.org/mule/dependencies/maven2"
and a dependency:
"oracle" % "ojdbc14" % "10.2.0.2"
You can do the same with maven. pom.xml and jar are available (http://dist.codehaus.org/mule/dependencies/maven2/oracle/ojdbc14/10.2.0.2/).
如果您使用的是 Netbeans,请转到“依赖项”并手动安装工件。 找到您下载的 .jar 文件并完成。 干净的构建将解决任何问题。
If you are using Netbeans, goto Dependencies and manually install artifact. Locate your downloaded .jar file and its done. clean build will solve any issues.
请尝试以下:
Please try below: