Java Maven:Oracle JDBC 驱动程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20465381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 02:09:01  来源:igfitidea点击:

Maven: Oracle JDBC driver

javamaven

提问by DaRoGa

I know this question has been asked a lot, but none of the solutions worked for me. I have a maven dependency to retrieve the OJDBC jar file for my project. The dependency looks like this:

我知道这个问题已经被问了很多,但没有一个解决方案对我有用。我有一个 maven 依赖项来检索我的项目的 OJDBC jar 文件。依赖项如下所示:

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3</version>
    </dependency>

The jar file is being downloaded into the .m2 folder absolutely fine and it shows up in the maven dependencies of the project. I know it is retrieving it OK because if I remove it from the pom.xml it is removed from the maven dependencies. However no matter what I have done, I cannot get rid of the following error:

jar 文件正在完全正常地下载到 .m2 文件夹中,它显示在项目的 maven 依赖项中。我知道它正在检索它,因为如果我从 pom.xml 中删除它,它将从 maven 依赖项中删除。但是,无论我做了什么,我都无法摆脱以下错误:

Missing artifact com.oracle:ojdbc6:jar:11.2.0.3

Can somebody please help. This is the same in all of my projects!!!

有人可以帮忙吗。这在我所有的项目中都是一样的!!!

采纳答案by Saif Asif

Due to binary licences , the Oracle driver is not present in the maven central repository. You can find some public repos that have hosted this jar to be made available for use but it is illegal as per the license.

由于二进制许可证,maven 中央存储库中不存在 Oracle 驱动程序。您可以找到一些托管此 jar 的公共存储库以供使用,但根据许可证,这是非法的。

it is obviously finding the jar file and downloading it as it is in my .m2 folder

it is obviously finding the jar file and downloading it as it is in my .m2 folder

There can be reasons why that jar is there ( or atleast you think it is )

那个罐子在那里可能是有原因的(或者至少你认为它是)

  1. Whenever maven fails to find some jar ( due to any reason whatsoever ) , it does generate the maven2 hierarchy of folders in the .m2/ but if you look closely you will notice that its not exactly a jar , but its extension will be like "someJarName.1.1.1.jar.lastUpdated". This is not a jar, this is just a convention used by maven to keep track of what jars it needs to re-download and re-check
  2. The second possibility is that the jar must have been manually inserted into the repository ( by the mvn install:install-filecommand and that is the reason its there. of-course I am assuming the fact that you haven't configured any other repository besides the default mvn central
  1. 每当 maven 无法找到某个 jar(无论出于何种原因)时,它都会在 .m2/ 中生成 maven2 文件夹层次结构,但如果仔细观察,您会发现它不完全是一个 jar,但它的扩展名将类似于“ someJarName.1.1.1.jar.lastUpdated”。这不是 jar,这只是 maven 用来跟踪需要重新下载和重新检查哪些 jar 的约定
  2. 第二种可能性是 jar 必须手动插入到存储库中(通过 mvninstall:install-file命令,这就是它在那里的原因。当然,我假设除了默认的 mvn central 之外你还没有配置任何其他存储库

If you have the jar file in your local m2 repo ( I suggest you verify by expanding it, making sure all its package contents are in order and also the size of the jar ) then you may have to tell Eclipse to look for the jar again. To do this goto Window-> Preferences-> Maven-> User settings-> hit the re-indexbutton and wait for a couple of minutes . And then see if this helps solve your problem

如果您的本地 m2 存储库中有 jar 文件(我建议您通过扩展它来验证,确保其所有包内容以及 jar 的大小),那么您可能需要告诉 Eclipse 再次查找该 jar . 为此,请转到窗口->首选项-> Maven->用户设置-> 点击重新索引按钮并等待几分钟。然后看看这是否有助于解决您的问题

Edit

编辑

Another possible solution would be to use the systemscope and specify the path of the jar on the local machine , although I highly discourage this.

另一种可能的解决方案是使用system范围并指定本地机器上 jar 的路径,尽管我非常不鼓励这样做。

回答by Paaske

Actually, it seems like the Oracle driver is not actually in the maven repository due to some binary licenses.

实际上,由于某些二进制许可证,Oracle 驱动程序似乎实际上并不在 maven 存储库中。

In short you'll have to download the jar-file manually and install it into your local maven repository.

简而言之,您必须手动下载 jar 文件并将其安装到本地 Maven 存储库中。

See this answer: Find Oracle JDBC driver in Maven repository

请参阅此答案:在 Maven 存储库中查找 Oracle JDBC 驱动程序