Issue with ojdbc jar in Maven

Viewed 18849

I've developed a project in Java 8 and I've installed the ojdbc jar in maven when I developed the project using java 8. Now I'm converting the project into java 7. While doing so, I'm facing issue with ojdbc.jar dependency in pom.xml. Its showing:

Missing artifact com.oracle:ojdbc7:jar:12.1.0

at oracle dependency tag. When I try to run the mvn install for ojdbc jar, that also throws an error.

[ERROR] Failed to execute goal on project SlotBookingAvailability: Could not resolve dependencies for project org.logicInfo.oms:SlotBookingAvailability:war:0.0. 1-SNAPSHOT: Failure to find com.oracle:ojdbc7:jar:12.1.0 in https://repo.maven.a pache.org/maven2 was cached in the local repository, resolution will not be reat tempted until the update interval of central has elapsed or updates are forced.

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.logicInfo.oms</groupId>
<artifactId>SlotBookingAvailability</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>SlotBookingAvailability</name>
<description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>


<properties>
    <start-class>org.logicInfo.oms.SlotBookingAvailability.SlotBookingAvailabilityApplication</start-class>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.7</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc7</artifactId>
        <version>12.1.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.json/json -->
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20180813</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

</project>

Can someone help me out of this?

3 Answers

I agree with the answer of karol Dowbecki
I give you more details for install
Download the jar from oracle's website
Add ojdbc7.jar to the local maven repository.

Open cmd window

run comand: mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0 -Dpackaging=jar -Dfile=G:/Jar/ojdbc7.jar

change the jar name location version to yours

then you will find the jar in your maven local repository ,such as ${mavenrepository}/com/oracle/ojdbc7/${yourversion}/

whdeMacBook-Pro:Downloads wh$ mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.2 -Dpackaging=jar -Dfile=ojdbc7.jar 
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.newSpark:SparkLearn >-----------------------
[INFO] Building SparkLearn 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ SparkLearn ---
[INFO] Installing /Users/wh/Downloads/ojdbc7.jar to /server/mavenrepository/com/oracle/ojdbc7/12.1.0.2/ojdbc7-12.1.0.2.jar
[INFO] Installing /var/folders/fc/23q8bt313pgbrxktr9f03ms80000gn/T/mvninstall7641723653608629745.pom to /server/mavenrepository/com/oracle/ojdbc7/12.1.0.2/ojdbc7-12.1.0.2.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.564 s
[INFO] Finished at: 2018-11-04T14:33:34+08:00
[INFO] -----------------------------------

then you can use your setting in your maven pom.xml

Oracle JDBC drviers (ojdbc6.jar, ojdbc7.jar, ojdbc8.jar) are not published into Maven Central repository due to Oracle license. If it worked before you must have installed it locally (e.g. by running mvn install:install-file) or used a repository other than Maven Central which had it.

You need to download the ojdbc7 from Oracle website manually and agree to OTN License Agreement. Ideally you would download the ojdbc7 JAR to match your Oracle Database server version (SELECT * FROM v$version).

Please download the Oracle JDBC drivers from either OTN or you can download these from Oracle Maven repository (maven.oracle.com). Refer to the blog for instructions on downloading it from Oracle Maven.

Related