403禁止从Oracle存储库访问jdbc驱动程序 [英] 403 Forbidden for jdbc driver from Oracle repository

查看:179
本文介绍了403禁止从Oracle存储库访问jdbc驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在编译时下载 odjbc7.jar ,以便我可以在Travis CI中运行所有测试。我在 gradle.properties 中添加了一个设置,以便它只下载用于构建的jar。



我的工具的用户将自己提供驱动程序,以免违反Oracles许可协议。



我在网上找到的所有解决方案都回答了问题,到一个本地的jar,这对我的CI构建或其他想构建应用程序不起作用的我不能分发ojdbc jar作为我的仓库的一部分。



<下面是我的 build.gradle
的相关部分我有属性 mavenOracleUsername mavenOraclePassword 在我的 gradle.properties 中(我检查过这些在Oracle单点登录上是正确的):

  def oracleUsername = hasProperty('mavenOracleUsername')? mavenOracleUsername:System.getenv('mavenOracleUsername')
def oraclePassword = hasProperty('mavenOraclePassword')? mavenOraclePassword:System.getenv('mavenOraclePassword')

存储库{
jcenter()

maven {
urlhttps://www.oracle .com / content / secure / maven / content
// urlhttps://maven.oracle.com
credentials {
username$ {oracleUsername}
密码$ {oraclePassword}
}
}
}

...

依赖关系{
编译组: 'com.oracle.jdbc',名称:'ojdbc7',版本:'12.1.0.2'
}

当我运行我的构建时,出现以下错误:

 无法解析配置的所有依赖关系:compileClasspath 。 
>无法解析com.oracle.jdbc:ojdbc7:12.1.0.2。
要求:
项目:
>无法解析com.oracle.jdbc:ojdbc7:12.1.0.2。
>无法获取资源'https://www.oracle.com/content/secure/maven/content/com/oracle/jdbc/ojdbc7/12.1.0.2/ojdbc7-12.1.0.2.pom'。
>无法GET'https://www.oracle.com/content/secure/maven/content/com/oracle/jdbc/ojdbc7/12.1.0.2/ojdbc7-12.1.0.2.pom'。从服务器收到的状态代码403:禁止

如果我更改凭据,则会收到401响应,如果我更改jar的版本我得到一个找不到版本库的错误。

解决方案

解决方案将驱动程序的版本升级到 ojdbc8



此链接有助于:



https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides



我的 build.gradle 现在看起来像:

  def oracleUsername = hasProperty('mavenOracleUsername')? mavenOracleUsername:System.getenv('mavenOracleUsername')
def oraclePassword = hasProperty('mavenOraclePassword')? mavenOraclePassword:System.getenv('mavenOraclePassword')

存储库{
jcenter()

maven {
urlhttps://www.oracle .com / content / secure / maven / content
// urlhttps://maven.oracle.com
credentials {
username$ {oracleUsername}
密码$ {oraclePassword}
}
}
}

...


依赖关系{
编译组:'com.oracle.jdbc',名称:'ojdbc8',版本:'12 .2.0.1'
}

我也记录了一个我在教程GitHub存储库中提出的问题:
$ b https://github.com/robin-a-meade/example-gradle-oracle/issues/1


I want to download the odjbc7.jar at compile time so that I can run all of my tests in Travis CI. I've added a setting in my gradle.properties so that it'll only download the jar for building.

Users of my tool will provide the driver themselves so as not to go against Oracles license agreements.

All of the solutions I have found online answer the question by saying to point to a local jar which won't work for my CI build or for others wanting to build the application (I can't distribute the ojdbc jar as part of my repository).

Below is the relevant sections of my build.gradle, I have the properties mavenOracleUsername and mavenOraclePassword in my gradle.properties (I have checked these are correct on the Oracle single-sign on site) :

def oracleUsername = hasProperty('mavenOracleUsername') ? mavenOracleUsername : System.getenv('mavenOracleUsername')
def oraclePassword = hasProperty('mavenOraclePassword') ? mavenOraclePassword : System.getenv('mavenOraclePassword')

repositories {
    jcenter()

    maven {
        url "https://www.oracle.com/content/secure/maven/content"
//        url "https://maven.oracle.com"
        credentials {
            username "${oracleUsername}"
            password "${oraclePassword}"
        }
    }
}

...

dependencies {
    compile group: 'com.oracle.jdbc', name: 'ojdbc7', version: '12.1.0.2'
}

When I run my build I get the following error:

Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not resolve com.oracle.jdbc:ojdbc7:12.1.0.2.
  Required by:
      project :
   > Could not resolve com.oracle.jdbc:ojdbc7:12.1.0.2.
      > Could not get resource 'https://www.oracle.com/content/secure/maven/content/com/oracle/jdbc/ojdbc7/12.1.0.2/ojdbc7-12.1.0.2.pom'.
         > Could not GET 'https://www.oracle.com/content/secure/maven/content/com/oracle/jdbc/ojdbc7/12.1.0.2/ojdbc7-12.1.0.2.pom'. Received status code 403 from server: Forbidden

If I change the credentials I get a 401 response and if I change the version of the jar I get a not found in repository error.

解决方案

I found the solution to be to upgrade the version of the driver to ojdbc8.

This link helped:

https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides

My build.gradle now looks like:

def oracleUsername = hasProperty('mavenOracleUsername') ? mavenOracleUsername : System.getenv('mavenOracleUsername')
def oraclePassword = hasProperty('mavenOraclePassword') ? mavenOraclePassword : System.getenv('mavenOraclePassword')

repositories {
    jcenter()

    maven {
        url "https://www.oracle.com/content/secure/maven/content"
//        url "https://maven.oracle.com"
        credentials {
            username "${oracleUsername}"
            password "${oraclePassword}"
        }
    }
}

...


dependencies {
    compile group: 'com.oracle.jdbc', name: 'ojdbc8', version: '12.2.0.1'
}

I have also documented an issue I raised on a tutorial GitHub repository:

https://github.com/robin-a-meade/example-gradle-oracle/issues/1

这篇关于403禁止从Oracle存储库访问jdbc驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆