在 Maven 存储库中查找 Oracle JDBC 驱动程序

发布于 2024-07-25 23:00:44 字数 477 浏览 11 评论 0原文

我想将 oracle jdbc 驱动程序作为依赖项(运行时范围)添加到我的项目中 - ojdbc14。 在 MVNrepository 站点中,放入 POM 中的依赖项是:

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

当然这不起作用,因为它不在 maven 使用的中央存储库中。 2 个问题:

  1. 如何找到包含此工件的存储库(如果有)?

  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:

  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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(22

眸中客 2024-08-01 23:00:45

这对我来说就像魅力一样。 我经历了多种方法,但这对我有所帮助。
确保遵循每个步骤并将 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.

人事已非 2024-08-01 23:00:45

对于依赖

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.2</version>
</dependency>

尝试

<repository>
    <id>mvnrepository</id>
    <url>http://nexus.saas.hand-china.com/content/repositories/rdc</url>
</repository>

For dependency

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.2</version>
</dependency>

Try

<repository>
    <id>mvnrepository</id>
    <url>http://nexus.saas.hand-china.com/content/repositories/rdc</url>
</repository>
执着的年纪 2024-08-01 23:00:45

已解决

  • 请执行以下设置来解决该错误

需要启用此存储库才能查找 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

  • Please do following settings to resolve the error

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


2024-08-01 23:00:44

如何找到包含此工件的存储库(如果有)?

不幸的是,由于二进制许可证,没有包含 Oracle 驱动程序 JAR 的公共存储库。 许多依赖项都会发生这种情况,但这不是 Maven 的错。 如果您碰巧发现包含该 JAR 的公共存储库,您可以确定这是非法的。

如何添加它以便 Maven 能够使用它?

一些由于许可证原因而无法添加的 JAR 在 Maven 中央存储库。 只需检查一下,它包含供应商的首选 Maven 信息:

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

...以及下载文件的 URL,在本例中为
http://www.oracle.com/technology/software/tech /java/sqlj_jdbc/index.html

下载 JAR 后,只需将其添加到您的计算机存储库(请注意,我从 POM 中提取了 groupId、artifactId 和版本):

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

用于生成 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:

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

...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):

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

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.

天煞孤星 2024-08-01 23:00:44

Oracle JDBC 驱动程序现已在 Oracle Maven 存储库(不在 Central)中提供。

<dependency>
    <groupId>com.oracle.jdbc</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.2</version>
</dependency>

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 驱动程序。

<dependency>
    <groupId>com.oracle.ojdbc</groupId>
    <artifactId>ojdbc10</artifactId>
    <version>19.3.0.0</version>
</dependency>

对于 Gradle 用户,请使用:

implementation 'com.oracle.ojdbc:ojdbc10:19.3.0.0'

无需用户注册。

更新 2020-03-02

Oracle 现在在 com.oracle.database 组 ID 下发布驱动程序。 有关更多信息,请参阅 Anthony Accioly 的回答。 谢谢安东尼。

与 JDK6、JDK7 和 JDK8 兼容的 Oracle JDBC 驱动

<dependency>
  <groupId>com.oracle.database.jdbc</groupId>
  <artifactId>ojdbc6</artifactId>
  <version>11.2.0.4</version>
</dependency>

程序 与 JDK8、JDK9 和 JDK11

<dependency>
  <groupId>com.oracle.database.jdbc</groupId>
  <artifactId>ojdbc8</artifactId>
  <version>19.3.0.0</version>
</dependency>

兼容的 Oracle JDBC 驱动程序 与 JDK10 和 JDK11 兼容的 Oracle JDBC 驱动程序

<dependency>
  <groupId>com.oracle.database.jdbc</groupId>
  <artifactId>ojdbc10</artifactId>
  <version>19.3.0.0</version>
</dependency>

The Oracle JDBC Driver is now available in the Oracle Maven Repository (not in Central).

<dependency>
    <groupId>com.oracle.jdbc</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.2</version>
</dependency>

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.

<dependency>
    <groupId>com.oracle.ojdbc</groupId>
    <artifactId>ojdbc10</artifactId>
    <version>19.3.0.0</version>
</dependency>

For Gradle users, use:

implementation 'com.oracle.ojdbc:ojdbc10:19.3.0.0'

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

<dependency>
  <groupId>com.oracle.database.jdbc</groupId>
  <artifactId>ojdbc6</artifactId>
  <version>11.2.0.4</version>
</dependency>

Oracle JDBC Driver compatible with JDK8, JDK9, and JDK11

<dependency>
  <groupId>com.oracle.database.jdbc</groupId>
  <artifactId>ojdbc8</artifactId>
  <version>19.3.0.0</version>
</dependency>

Oracle JDBC Driver compatible with JDK10 and JDK11

<dependency>
  <groupId>com.oracle.database.jdbc</groupId>
  <artifactId>ojdbc10</artifactId>
  <version>19.3.0.0</version>
</dependency>
晨曦慕雪 2024-08-01 23:00:44

无论出于何种原因,我都无法使上述任何解决方案发挥作用。 (仍然不能。)

我所做的是将 jar 包含在我的项目中(blech),然后为其创建一个“系统”依赖项来指示 jar 的路径。 这可能不是正确的方法,但它确实有效。 并且它消除了团队中其他开发人员(或设置构建服务器的人员)将 jar 放入本地存储库的需要。

更新:当我运行 Hibernate Tools 时,此解决方案适用于我。 然而,它似乎不适用于构建 WAR 文件。 它不包括目标 WAR 文件中的 ojdbc6.jar 文件。

1)在项目的根目录中创建一个名为“lib”的目录。

2) 将 ojdbc6.jar 文件复制到那里(无论该 jar 的名称是什么。)

3) 创建一个如下所示的依赖项:

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc</artifactId>
    <version>14</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/ojdbc6.jar</systemPath> <!-- must match file name -->
</dependency>

丑陋,但对我有用。

要将文件包含在 war 文件中,请将以下内容添加到您的 pom 中

<build>
    <finalName>MyAppName</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webResources>
                    <resource>
                        <directory>${basedir}/src/main/java</directory>
                        <targetPath>WEB-INF/classes</targetPath>
                        <includes>
                            <include>**/*.properties</include>
                            <include>**/*.xml</include>
                            <include>**/*.css</include>
                            <include>**/*.html</include>
                        </includes>
                    </resource>
                    <resource>
                        <directory>${basedir}/lib</directory>
                        <targetPath>WEB-INF/lib</targetPath>
                        <includes>
                            <include>**/*.jar</include>
                        </includes>
                    </resource>
                </webResources>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

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:

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc</artifactId>
    <version>14</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/ojdbc6.jar</systemPath> <!-- must match file name -->
</dependency>

Ugly, but works for me.

To include the files in the war file add the following to your pom

<build>
    <finalName>MyAppName</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webResources>
                    <resource>
                        <directory>${basedir}/src/main/java</directory>
                        <targetPath>WEB-INF/classes</targetPath>
                        <includes>
                            <include>**/*.properties</include>
                            <include>**/*.xml</include>
                            <include>**/*.css</include>
                            <include>**/*.html</include>
                        </includes>
                    </resource>
                    <resource>
                        <directory>${basedir}/lib</directory>
                        <targetPath>WEB-INF/lib</targetPath>
                        <includes>
                            <include>**/*.jar</include>
                        </includes>
                    </resource>
                </webResources>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>
妳是的陽光 2024-08-01 23:00:44

下载 jar 并将其放入项目 src/lib 中。 现在您可以使用 Maven 安装程序插件了。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.3.1</version>
    <executions>
        <execution>
            <id>install-oracle-jdbc</id>
            <goals>
                <goal>install-file</goal>
            </goals>
            <phase>clean</phase>
            <configuration>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc6</artifactId>
                <version>11.2.0</version>
                <packaging>jar</packaging>
                <generatePom>true</generatePom>
                <createChecksum>true</createChecksum>
                <file>${project.basedir}/src/lib/ojdbc6.jar</file>
            </configuration>
        </execution>
    </executions>
</plugin>

现在您只需执行一次mvn clean,oracle lib就会安装在您的本地maven存储库中。

Download the jar and place it in your project src/lib. Now you can use the maven installer plugin.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.3.1</version>
    <executions>
        <execution>
            <id>install-oracle-jdbc</id>
            <goals>
                <goal>install-file</goal>
            </goals>
            <phase>clean</phase>
            <configuration>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc6</artifactId>
                <version>11.2.0</version>
                <packaging>jar</packaging>
                <generatePom>true</generatePom>
                <createChecksum>true</createChecksum>
                <file>${project.basedir}/src/lib/ojdbc6.jar</file>
            </configuration>
        </execution>
    </executions>
</plugin>

Now you only have to execute mvn clean once and the oracle lib is installed in your local maven repository.

累赘 2024-08-01 23:00:44

Oracle 现在在 maven.oracle.com 上公开了一个 Maven 存储库
但是您需要经过身份验证。

参阅 https://blogs.oracle.com/WebLogicServer/entry/weblogic_server_and_the_oracle

请 博客文章中的评论 ojdbc 驱动程序应该在以下坐标处可用:

<groupId>com.oracle.weblogic</groupId>
 <artifactId>ojdbc7</artifactId>
 <version>12.1.3-0-0</version>
 <packaging>jar</packaging>

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:

<groupId>com.oracle.weblogic</groupId>
 <artifactId>ojdbc7</artifactId>
 <version>12.1.3-0-0</version>
 <packaging>jar</packaging>
夏了南城 2024-08-01 23:00:44

尝试使用:

<repositories>
    <!-- Repository for ORACLE ojdbc6. -->
    <repository>
        <id>codelds</id>
        <url>https://code.lds.org/nexus/content/groups/main-repo</url>
    </repository>
</repositories>
<dependencies> 
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3</version>
    </dependency>
</dependencies> 

Try with:

<repositories>
    <!-- Repository for ORACLE ojdbc6. -->
    <repository>
        <id>codelds</id>
        <url>https://code.lds.org/nexus/content/groups/main-repo</url>
    </repository>
</repositories>
<dependencies> 
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3</version>
    </dependency>
</dependencies> 
与往事干杯 2024-08-01 23:00:44

1. 如何找到包含此工件的存储库(如果有)?

由于 DavidS 已评论我在回答时引用的行不再存在于当前(在我现在正在写)我链接的 OTN 许可协议。 仅针对旧版本的工件考虑此答案,例如 10.2.0.3.0 等。

所有 Oracle 数据库 JDBC 驱动程序OTN 许可协议

如果您阅读 OTN 许可协议,您会发现以下许可条款:

你不可以:
...
- 分发程序,除非附带您的应用程序;
...

这就是为什么你无法在任何公共 Maven 存储库中找到驱动程序的 jar,因为它将单独分发,如果发生这种情况,将违反许可证。

添加依赖项:(

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

或任何更高版本)使 Maven 仅下载 ojdbc14-10.2.0.3.0.pom,并且在该 pom 中您可以阅读:

...
<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>
...

它会通知您有关 OTN 许可证的信息。

2.如何添加它以便Maven使用它?

为了使上述依赖项起作用,我同意victor Hugo,他建议你此处手动将 jar 安装到本地 Maven 存储库中(. m2 目录)通过运行:

mvn install:install-file -Dfile={Path_to_your_ojdbc.jar} -DgroupId=com.oracle 
-DartifactId=ojdbc -Dversion=10.2.0.3.0 -Dpackaging=jar

但我想补充一点,上面的许可条款不仅限制了您无法找到 JDBC jar 的位置,还限制了您安装它的位置!

事实上,你的本地 Maven 存储库必须是私有的,而不是共享的,因为如果它是共享的,那么它将是一种单独分发 jar 的发行版,即使是一小群人进入你的本地区域网络,这代表了违反 OTN 许可协议

此外,我认为您应该避免在公司存储库管理器中安装 JDBC jar(例如 ArtifactoryNexus) 作为单个工件,因为如果安装了它,它将仍然单独分发,即使仅分发给组织中的人员,这表示违反了 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:

You may not:
...
- distribute the programs unless accompanied with your applications;
...

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:

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

(or any later version) make Maven downloads the ojdbc14-10.2.0.3.0.pom only, and in that pom you can read:

...
<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>
...

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:

mvn install:install-file -Dfile={Path_to_your_ojdbc.jar} -DgroupId=com.oracle 
-DartifactId=ojdbc -Dversion=10.2.0.3.0 -Dpackaging=jar

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.

吹泡泡o 2024-08-01 23:00:44

您可以使用 Nexus 管理第 3 方依赖项以及标准 Maven 存储库中的依赖项。

You can use Nexus to manage 3rd party dependencies as well as dependencies in standard maven repositories.

血之狂魔 2024-08-01 23:00:44

截至今天(2020 年 2 月 27 日)Oracle 宣布已在 Maven Central 组 id com.oracle.database:

示例:

<dependency>
  <groupId>com.oracle.database.jdbc</groupId>
  <artifactId>ojdbc10</artifactId>
  <version>19.3.0.0</version>
</dependency>

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:

<dependency>
  <groupId>com.oracle.database.jdbc</groupId>
  <artifactId>ojdbc10</artifactId>
  <version>19.3.0.0</version>
</dependency>
白龙吟 2024-08-01 23:00:44

到目前为止,还无法使用 Maven 存储库。 我使用 ivy 作为依赖管理工具,但也使用 maven2 的 ibiblio 存储库。 这适用于 ivy:

<dependency org="oracle" name="ojdbc14" rev="10.2.0.2" conf="*->default"/>

Maven2 的依赖关系可能是这样的:

<dependency> 
    <groupId>oracle</groupId> 
    <artifactId>ojdbc14</artifactId> 
    <version>10.2.0.2</version> 
</dependency>

注意我定义了 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:

<dependency org="oracle" name="ojdbc14" rev="10.2.0.2" conf="*->default"/>

Maven2' s dependency could be something like that:

<dependency> 
    <groupId>oracle</groupId> 
    <artifactId>ojdbc14</artifactId> 
    <version>10.2.0.2</version> 
</dependency>

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.

音盲 2024-08-01 23:00:44

Oracle JDBC 驱动程序现在可以在Maven Central中使用。
链接如下:

Oracle JDBC 驱动程序 - Maven Central

Oracle 开发人员文章宣布推出Maven Central 中的 Oracle JDBC 驱动程序:

Oracle 宣布 - Oracle JDBC 驱动程序在 Maven Central 中可用

示例:

<!-- https://mvnrepository.com/artifact/com.oracle.jdbc/ojdbc10 -->
<dependency>
   <groupId>com.oracle.database.jdbc</groupId>
   <artifactId>ojdbc10</artifactId>
   <version>19.3.0.0</version>
</dependency>

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:

<!-- https://mvnrepository.com/artifact/com.oracle.jdbc/ojdbc10 -->
<dependency>
   <groupId>com.oracle.database.jdbc</groupId>
   <artifactId>ojdbc10</artifactId>
   <version>19.3.0.0</version>
</dependency>
樱娆 2024-08-01 23:00:44

就我而言,在添加以下版本依赖项(10.2.0.4)后,它对我有用。 添加此版本 10.2.0.3.0 后,由于 .jar 文件在存储库路径中不可用,因此它不起作用。

<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4</version>

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.

<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4</version>
满地尘埃落定 2024-08-01 23:00:44

我在 LGPLv2 下发布开源代码,甚至在与 Oracle 进行多次电子邮件对话后,他们仍不清楚我是否可以在我的发行版中发布他们的二进制 JDBC 驱动程序。 该问题与我的许可证是否与他们的 OTN 条款兼容有关,因此他们建议不允许我运送驱动程序。 大概与这部分有关

(b) 将包含您开发的应用程序的程序分发给您的客户,前提是每个此类被许可人都同意与本协议条款一致的许可条款

因此,即使您设法在您的专有/本地 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

(b) to distribute the programs with applications you have developed to your customers provided that each such licensee agrees to license terms consistent with the terms of this Agreement

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.

生寂 2024-08-01 23:00:44

您可以在 此处<找到在 Maven 项目上使用 Oracle JDBC 驱动程序的 Github 简单示例项目/a>.

您可以找到持续集成的所有说明 + 示例并在 Travis-CI 上运行。

DEMO

pom.xml

<properties>
    <oracle.driver.version>12.2.0.1</oracle.driver.version>
</properties>

<repositories>
    <repository>
        <id>maven.oracle.com</id>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <url>https://maven.oracle.com</url>
        <layout>default</layout>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>maven.oracle.com</id>
        <url>https://maven.oracle.com</url>
    </pluginRepository>
</pluginRepositories>

<dependencies>
    <dependency>
        <groupId>com.oracle.jdbc</groupId>
        <artifactId>ojdbc8</artifactId>
        <version>${oracle.driver.version}</version>
    </dependency>
</dependencies>

mvnsettings .xml

<settings>
    <servers>
        <server>
            <id>maven.oracle.com</id>
            <username>${OTN_USERNAME}</username>
            <password>${OTN_PASSWORD}</password>
            <configuration>
                <basicAuthScope>
                    <host>ANY</host>
                    <port>ANY</port>
                    <realm>OAM 11g</realm>
                </basicAuthScope>
                <httpConfiguration>
                    <all>
                        <params>
                            <property>
                                <name>http.protocol.allow-circular-redirects</name>
                                <value>%b,true</value>
                            </property>
                        </params>
                    </all>
                </httpConfiguration>
            </configuration>
        </server>
    </servers>
</settings>

如何在本地环境中使用

通过 Oracle 登录名在 test/mvnsettings.xml 文件

更改 ${OTN_PASSWORD} 中更改 ${OTN_USERNAME} 通过 test/mvnsettings.xml 文件中的 Oracle 密码

mvn clean install --settings test/mvnsettings.xml

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

<properties>
    <oracle.driver.version>12.2.0.1</oracle.driver.version>
</properties>

<repositories>
    <repository>
        <id>maven.oracle.com</id>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <url>https://maven.oracle.com</url>
        <layout>default</layout>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>maven.oracle.com</id>
        <url>https://maven.oracle.com</url>
    </pluginRepository>
</pluginRepositories>

<dependencies>
    <dependency>
        <groupId>com.oracle.jdbc</groupId>
        <artifactId>ojdbc8</artifactId>
        <version>${oracle.driver.version}</version>
    </dependency>
</dependencies>

mvnsettings.xml

<settings>
    <servers>
        <server>
            <id>maven.oracle.com</id>
            <username>${OTN_USERNAME}</username>
            <password>${OTN_PASSWORD}</password>
            <configuration>
                <basicAuthScope>
                    <host>ANY</host>
                    <port>ANY</port>
                    <realm>OAM 11g</realm>
                </basicAuthScope>
                <httpConfiguration>
                    <all>
                        <params>
                            <property>
                                <name>http.protocol.allow-circular-redirects</name>
                                <value>%b,true</value>
                            </property>
                        </params>
                    </all>
                </httpConfiguration>
            </configuration>
        </server>
    </servers>
</settings>

How to use on local environment

change ${OTN_USERNAME} by your Oracle login in test/mvnsettings.xml file

change ${OTN_PASSWORD} by your Oracle password in test/mvnsettings.xml file

mvn clean install --settings test/mvnsettings.xml
野味少女 2024-08-01 23:00:44

简化的黑客 - 为我工作

第 1 步:
将您的依赖项更改为

<dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc7</artifactId>
        <version>12.1.0.2</version></dependency>

第 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

<dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc7</artifactId>
        <version>12.1.0.2</version></dependency>

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

浪推晚风 2024-08-01 23:00:44

有一个 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/).

中性美 2024-08-01 23:00:44

如果您使用的是 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.

百思不得你姐 2024-08-01 23:00:44

请尝试以下:

<dependency>
    <groupId>com.oracle.ojdbc</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>19.3.0.0</version>
</dependency>

Please try below:

<dependency>
    <groupId>com.oracle.ojdbc</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>19.3.0.0</version>
</dependency>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文