Oracle JDBC 7作为Maven依赖项

Sam*_*Sam 6 java oracle jdbc maven

我正在尝试将Oracle JDBC作为maven依赖项添加到我的项目中.我已经在线阅读了多个教程,这些教程提出了添加第三方依赖关系的各种方法.

我选择了本地安装方法,但是(像这个人)我遇到了问题.

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

mvn install:install-file -Dfile={lib/ojdbc7.jar} -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.1 -Dpackaging=jar
Run Code Online (Sandbox Code Playgroud)

并成功:

[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
Run Code Online (Sandbox Code Playgroud)

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

 <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc7</artifactId>
            <version>12.1.0.1</version>
 </dependency>
Run Code Online (Sandbox Code Playgroud)

然而,当我编译时,我得到以下内容:

[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
Run Code Online (Sandbox Code Playgroud)

我玩过这些-U-o旗帜无济于事.我也尝试通过首先将lib安装到lib目录中(正如Raghuram在另一个问题上所建议的那样)而没有任何改变.

Pra*_*K S 1

解决方案

  1. 手动将此ojdbc7-12.1.0.1.jar文件放入本地 Maven/缓存存储库中。
  2. 当您在本地 Maven 存储库中使用第 3 方 Jar/专有 JAR 文件时,请使用mvn 部署目标。