尝试将 ojdbc7 作为 maven 依赖项安装时出现问题 [重复]
Posted
技术标签:
【中文标题】尝试将 ojdbc7 作为 maven 依赖项安装时出现问题 [重复]【英文标题】:problems trying to install ojdbc7 as a maven dependency [duplicate] 【发布时间】:2020-04-22 08:49:13 【问题描述】:我在尝试使用 maven 构建我的项目时遇到问题,更具体地说,当需要依赖项时,Oracle JDBC 7 的依赖项,我一直在寻找解决方案几个小时,甚至咨询了一些关于该问题的问题在这里,但什么都没有
C:\Users\E10697\Desktop\Contenedores\oracle_contenedores\Entorno-Oracle-sobre-Docker-master\4。 Consumo de la Oracle DB a través de un API Rest\4.1。详细说明 API 休息\4.1.2。实现 API Rest\OpenwebinarDockerAPI - RESUELTO\OPENWE~1>mvn clean install
错误:[错误] 无法在项目 app-rest-api 上执行目标:无法解析项目 openwebinar.marvel.app:app-rest-api:war:0.1.0-SNAPSHOT 的依赖项:可以在 spring-milestones (https://repo.spring.io/milestone) 中找不到工件 com.oracle:ojdbc7:jar:12.1.0
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] rest-api [pom]
[INFO] app-rest-api [war]
[INFO] app-web [war]
[INFO]
[INFO] ---------------------< openwebinar.marvel.app:app >---------------------
[INFO] Building rest-api 0.1.0-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ app ---
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ app ---
[INFO] Installing C:\Users\E10697\Desktop\Contenedores\oracle_contenedores\Entorno-Oracle-sobre-Docker-master\4. Consumo de la Oracle DB a través de un API Rest\4.1. Elaboración del API Rest\4.1.2. Implementación de una API Rest\OpenwebinarDockerAPI - RESUELTO\OPENWE~1\pom.xml to C:\Users\E10697\.m2\repository\openwebinar\marvel\app\app\0.1.0-SNAPSHOT\app-0.1.0-SNAPSHOT.pom
[INFO]
[INFO] ----------------< openwebinar.marvel.app:app-rest-api >-----------------
[INFO] Building app-rest-api 0.1.0-SNAPSHOT [2/3]
[INFO] --------------------------------[ war ]---------------------------------
Downloading from spring-milestones: https://repo.spring.io/milestone/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.pom
Downloading from repository.springframework.maven.release: http://maven.springframework.org/milestone/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.pom
Downloading from org.springframework: http://maven.springframework.org/snapshot/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.pom
Downloading from spring-milestone: http://repo.spring.io/libs-milestone/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.pom
Downloading from spring-release: http://repo.spring.io/libs-release/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.pom
Downloading from central: https://repo.maven.apache.org/maven2/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.pom
[WARNING] The POM for com.oracle:ojdbc7:jar:12.1.0 is missing, no dependency information available
Downloading from spring-milestones: https://repo.spring.io/milestone/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.jar
Downloading from repository.springframework.maven.release: http://maven.springframework.org/milestone/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.jar
Downloading from org.springframework: http://maven.springframework.org/snapshot/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.jar
Downloading from spring-milestone: http://repo.spring.io/libs-milestone/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.jar
Downloading from spring-release: http://repo.spring.io/libs-release/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.jar
Downloading from central: https://repo.maven.apache.org/maven2/com/oracle/ojdbc7/12.1.0/ojdbc7-12.1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for rest-api 0.1.0-SNAPSHOT:
[INFO]
[INFO] rest-api ........................................... SUCCESS [ 0.590 s]
[INFO] app-rest-api ....................................... FAILURE [ 3.732 s]
[INFO] app-web ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.762 s
[INFO] Finished at: 2020-01-03T15:36:54-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project app-rest-api: Could not resolve dependencies for project openwebinar.marvel.app:app-rest-api:war:0.1.0-SNAPSHOT: Could not find artifact com.oracle:ojdbc7:jar:12.1.0 in spring-milestones (https://repo.spring.io/milestone) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :app-rest-api
app-rest-api 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>
<artifactId>app-rest-api</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>openwebinar.marvel.app</groupId>
<artifactId>app</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
我的项目结构,在这种情况下,我在 operwebinar_mavel 文件夹中运行 mvn clean install 命令:
maven 路由里有什么:
C:\Users\E10697\.m2\repository\com\oracle\ojdbc7\12.1.0
【问题讨论】:
Hola Cesar,您是否检查过 oracle 驱动程序实际上位于您正在使用的默认 maven 存储库中?,我遇到了类似的问题,不得不添加驱动程序所在的相应存储库。 这能回答你的问题吗? Find Oracle JDBC driver in Maven repository 它对我有用非常感谢你,这个问题没有回答我的问题***.com/questions/1074869/… 【参考方案1】:将存储库添加到您的 POM 中,它将起作用:
<repositories>
<repository>
<id>hand-china-repo</id>
<name>HandChinaRepo</name>
<url>http://nexus.saas.hand-china.com/content/repositories/rdc/</url>
</repository>
</repositories>
存储库在 Maven 存储库页面上列出: https://mvnrepository.com/artifact/com.oracle/ojdbc7/12.1.0.2
Maven Central 在版本 12.1.0.2 报告了类似的依赖关系。尝试更改您的 POM 以匹配:
<!-- https://mvnrepository.com/artifact/com.oracle/ojdbc7 -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>
我进行了测试,添加 repo 和确切版本的组合对我有用。
【讨论】:
mvnrepository 与 MavenCentral 无关。 已更正。谢谢。 这违反了 Oracle 的许可,该许可禁止在任何公共存储库中发布 ojdbc7.jar。 它对我有用非常感谢你,这个问题没有回答我的问题***.com/questions/1074869/…以上是关于尝试将 ojdbc7 作为 maven 依赖项安装时出现问题 [重复]的主要内容,如果未能解决你的问题,请参考以下文章
有没有办法在 maven 尝试解决它们之前安装 maven 依赖项?
如何在不使用任何插件的情况下将非 maven 依赖项安装到您的 maven 项目中? [复制]
如何将本地项目(不是 jar)作为依赖项添加到 Maven 项目
Jeddict 插件安装失败 - Apache Netbeans 12 - 缺少“Maven Projects”插件依赖项