Maven 中的 ojdbc jar 问题

Issue with ojdbc jar in Maven

我在Java8中开发了一个项目,在使用java8开发项目时,我在maven中安装了ojdbc jar。现在我正在将项目转换成java 7. 这样做时,我面临 pom.xmlojdbc.jar 依赖的问题。它显示:

Missing artifact com.oracle:ojdbc7:jar:12.1.0

在 oracle 依赖项标记中。当我尝试 运行 ojdbc jar 的 mvn 安装时,也会引发错误。

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

有人可以帮我解决这个问题吗?

由于 Oracle 许可,

Oracle JDBC 驱动程序(ojdbc6.jarojdbc7.jarojdbc8.jar)未发布到 Maven 中央存储库。如果它在您必须在本地安装它之前工作(例如通过 运行 mvn install:install-file)或使用了除 Maven Central 以外的存储库。

您需要从 Oracle 网站手动下载 ojdbc7 并同意 OTN 许可协议。理想情况下,您将下载 ojdbc7 JAR 以匹配您的 Oracle 数据库服务器版本 (SELECT * FROM v$version)。

我同意 karol Dowbecki 的回答
我给你更多的安装细节
oracle's website
下载 jar 将 ojdbc7.jar 添加到本地 maven 存储库。

打开命令window

运行 命令:mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0 -Dpackaging=jar -Dfile=G:/Jar/ojdbc7.jar

将 jar 名称位置版本更改为您的

然后你会在你的maven本地仓库中找到jar,比如${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] -----------------------------------

然后你可以在你的maven中使用你的设置pom.xml

请从 OTN or you can download these from Oracle Maven repository (maven.oracle.com). Refer to the blog 下载 Oracle JDBC 驱动程序以获取有关从 Oracle Maven 下载它的说明。