将此JAR放入我的本地仓库的正确方法是什么?

时间:2011-05-09 18:20:36

标签: maven maven-3

我正在使用Maven 3.0.3。显然,Oracle JDBC驱动程序在公共Maven仓库中不可用,因此我将其简化为将其安装到本地仓库。所以我创建了这个文件

~/.m2/repository/oracle/oracle/10.2.0.3.0/classes12.jar

我在我的pom.xml文件中有这个...

<dependency>
  <groupId>oracle</groupId>
  <artifactId>classes12</artifactId>
  <version>10.2.0.3.0</version>
</dependency>

然而,在运行maven时,我收到了这个错误。如何构建我的本地仓库? - 戴夫

[ERROR] Failed to execute goal on project infinitiusa_leads_testing: Could not resolve dependencies for project infinitiusa_leads_testing:infinitiusa_leads_testing:jar:1.0-SNAPSHOT: Failure to find oracle:classes12:jar:10.2.0.3.0 in http://repo1.maven.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

1 个答案:

答案 0 :(得分:2)

首先,您必须安装该文件在存储库中,而不仅仅是将其复制到正确的目录中。请参阅答案:Find Oracle JDBC driver in Maven repository

其次,目录实际上是不对的。对于您在pom.xml中提供的依赖项,它应该位于:

~/.m2/repository/oracle/classes12/10.2.0.3.0/classes12-10.2.0.3.0.jar

但这由install:install-file处理,不要手动操作存储库目录(除了删除一些东西,maven有时会感到困惑,它需要 restart ,但这是一个不同的故事)。

mvn install:install-file -DgroupId=oracle -DartifactId=classes12 \
 -Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=classes12.jar

BTW将com.oracle视为groupId

maven通常会提供非常准确的命令行,您应该运行该命令行以在本地存储库中安装缺少的依赖项。不知道为什么在你的情况下没有发生。