Oracle JDBC 7 作为 Maven 依赖项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30000067/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:50:48  来源:igfitidea点击:

Oracle JDBC 7 as Maven dependency

javaoraclemavenjdbc

提问by Sam

I'm attempting to add Oracle JDBC to my project as a maven dependency. I've followed multiple tutorials online which suggest various means to add a third party dependency.

我正在尝试将 Oracle JDBC 作为 maven 依赖项添加到我的项目中。我在网上学习了多个教程,其中提出了添加第三方依赖项的各种方法。

I've opted for the local installation method, but like (this person) I'm experiencing issues.

我选择了本地安装方法,但就像(此人)一样,我遇到了问题。

I run the following command to install the jar:

我运行以下命令来安装 jar:

mvn install:install-file -Dfile={lib/ojdbc7.jar} -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.1 -Dpackaging=jar

and it succeeds with:

它成功了:

[INFO] --- maven-install-plugin:2.3:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /home/<myfolder>/{lib/ojdbc7.jar} to /home/<myname>/.m2/repository/com/oracle/ojdbc7/12.1.0.1/ojdbc7-12.1.0.1.jar

I have then added the following to my pom:

然后我将以下内容添加到我的 pom 中:

 <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc7</artifactId>
            <version>12.1.0.1</version>
 </dependency>

and yet when I compile I get the following:

然而,当我编译时,我得到以下信息:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.307s
[INFO] Finished at: Sat May 02 20:40:07 NZST 2015
[INFO] Final Memory: 8M/56M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project xxx: Could not resolve dependencies for project com.xxx:xxx:jar:1.0-SNAPSHOT: Failure to find com.oracle:ojdbc7:jar:12.1.0.1 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [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

I've played around with the -Uand -oflags to no avail. I have also tried installing the jar by first cding into the lib directory (as suggested by Raghuram on the other question) with no change.

我玩过-U-o标志无济于事。我还尝试通过首先将 jar 放入 lib 目录(如 Raghuram 在另一个问题上所建议的)而不做任何更改来安装 jar。

回答by Praveen Kumar K S

Solution

解决方案

  1. Manually place this ojdbc7-12.1.0.1.jarfile in your Local Maven/Cache Repository.
  2. Use mvn deploy goalwhile you are using 3rd Party Jar/Proprietary JAR Files in your Local Maven Repository.
  1. 手动将此ojdbc7-12.1.0.1.jar文件放置在您的本地 Maven/缓存存储库中。
  2. 当您在本地 Maven 存储库中使用 3rd Party Jar/专有 JAR 文件时,请使用mvn deploy 目标