[英]Cannot add local jar files in maven project
我正在嘗試重新打包log4j,以便我可以在Android上使用它。 為了做到這一點,我必須使用openbeans庫並用com.googlecode.openbeans
替換每個java.beans
。
顯然這還不夠,因為在重新打包通過maven log4j之前,我要在項目中包含openbeans-1.0.jar
。
所以我找到了這種方法。
我通過以下命令安裝了openbeans:
mvn install:install-file -Dfile=/home/luca/openbeans-1.0.jar -DgroupId=com.googlecode -DartifactId=openbeans -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
我已檢查正確執行命令檢查.jar
存在於以下路徑中(並且確實如此):
~/.m2/repository/com/googlecode/openbeans/1.0/openbeans-1.0.jar
然后我編輯了pom.xml
文件,添加:
<dependency>
<groupId>com.googlecode</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
</dependency>
但是,如果我嘗試mvn package
則會返回此錯誤:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.2:run (rmdir_tests_output) on project log4j: Execution rmdir_tests_output of goal org.apache.maven.plugins:maven-antrun-plugin:1.2:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.2 or one of its dependencies could not be resolved: Failure to find com.googlecode:openbeans:jar:1.0 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]
就像install-file
沒有用。
我也試過這個方法,使用下面的代碼(顯然我復制了項目根目錄中的.jar
):
<dependency>
<groupId>com.googlecode</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/openbeans-1.0.jar</systemPath>
</dependency>
這里返回的錯誤是:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-compile) on project log4j: Compilation failure
[ERROR] /home/luca/apache-log4j-1.2.17/src/main/java/org/apache/log4j/config/PropertyGetter.java:[31,21] error: package com.googlecode does not exist
我在做什么有什么問題?
即使我仍然不明白為什么,我發現執行:
mvn install:install-file -Dfile=/home/luca/openbeans-1.0.jar -DgroupId=com.googlecode.openbeans -DartifactId=openbeans -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
並在pom中使用:
<dependency>
<groupId>com.googlecode.openbeans</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
</dependency>
編譯時沒有錯誤。 但正如我所說,仍然在想為什么。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.