Java Eclipse 中缺少工件 com.oracle:ojdbc7
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32000104/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Missing artifact com.oracle:ojdbc7 in eclipse
提问by Masih
I have imported a Maven Project in Eclipse (EE Developer) and I have in my pom.xml file the following error, “Missing artifact com.oracle:ojdbc7:jar:12.1.0.2″ in this code:
我在 Eclipse(EE 开发人员)中导入了一个 Maven 项目,并且在我的 pom.xml 文件中出现以下错误,“在这段代码中缺少工件 com.oracle:ojdbc7:jar:12.1.0.2”:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>
I have done so by downloading the ojdbc7.jar and run this command:
我通过下载 ojdbc7.jar 并运行以下命令来完成此操作:
mvn install:install-file -Dfile=/Path-to-jar/ojdbc7.jar
-DgroupId=com.oracle
-DartifactId=ojdbc7
-Dversion=12.1.0.2
-Dpackaging=jar
-DgeneratePom=true
After that, I got as an output BUILD SUCCESS, and if I go to the .m2 folder I see in the com->oracle->ojdbc7 two files called “ojdbc7-12.1.0.1.jar.lastUpdated” and “ojdbc7-12.1.0.1.pom.lastUpdated” but still Eclipse brings me the code into the pom.xml file as an error?!?!?! Can some one help?
之后,我得到了 BUILD SUCCESS 的输出,如果我转到 .m2 文件夹,我会在 com->oracle->ojdbc7 中看到两个名为“ojdbc7-12.1.0.1.jar.lastUpdated”和“ojdbc7-12.1”的文件.0.1.pom.lastUpdated”但Eclipse仍然将代码作为错误带入pom.xml文件中?!?!?!有人可以帮忙吗?
回答by Franck
I would get rid of those 2 files manually (lastUpdated) then re-run your install command and finally build your project. Those 2 files have been created by mvn as flags to avoid refetching them for a certain amount of time. They certainly have been created prior to your manual install-file command.
我会手动删除这 2 个文件(lastUpdated),然后重新运行您的安装命令并最终构建您的项目。这两个文件已由 mvn 创建为标志,以避免在一定时间内重新获取它们。它们肯定是在您手动安装文件命令之前创建的。
回答by Vicky
I recommend you to follow the instruction given in this link. "http://javabycode.com/build-tools/maven/add-oracle-jdbc-driver-maven.html"
我建议您按照此链接中给出的说明进行操作。" http://javabycode.com/build-tools/maven/add-oracle-jdbc-driver-maven.html"
As per your dependency in pom.xml there should be 4 files generated inside "m2repo\com\oracle\ojdbc7\12.1.0.2" folder.
根据您在 pom.xml 中的依赖项,应该在“m2repo\com\oracle\ojdbc7\12.1.0.2”文件夹中生成 4 个文件。
- ojdbc7-12.1.0.2.jar
- ojdbc7-12.1.0.2.jar.lastUpdated
- ojdbc7-12.1.0.2.pom
- ojdbc7-12.1.0.2.pom.lastUpdated
- ojdbc7-12.1.0.2.jar
- ojdbc7-12.1.0.2.jar.lastUpdated
- ojdbc7-12.1.0.2.pom
- ojdbc7-12.1.0.2.pom.lastUpdated
But as you are saying you checked for "ojdbc7-12.1.0.1.jar.lastUpdated", that should not be the case. I recommend you to delete your dependency folder and then start from scratch.
但是,正如您所说,您检查了“ojdbc7-12.1.0. 1.jar.lastUpdated”,事实并非如此。我建议你删除你的依赖文件夹,然后从头开始。
回答by Moritz
After successfully running the "mvn install" command right click your Project -> Maven -> Update Project(or Alt+F5).
成功运行“mvn install”命令后,右键单击您的项目 -> Maven -> 更新项目(或 Alt+F5)。
回答by mannedear
Some how the jar is not getting downloaded into the local pc. I opened the maven site https://mvnrepository.com/artifact/com.oracle/ojdbc7/12.1.0.2and downloaded the required jar and placed it in to the .m2 folder, and the error is gone.
jar 没有下载到本地 PC 的一些方法。我打开maven站点https://mvnrepository.com/artifact/com.oracle/ojdbc7/12.1.0.2下载了需要的jar放到.m2文件夹下,错误就没有了。