網頁

2020/9/16

Maven 安裝目錄檔案到本地倉庫發生指定檔案不存在錯誤 install file to local repository specified file not exists

在Windows有pom.xml的目錄以cmd執行Maven的mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>命令來安裝檔案到local repository時發生錯誤。

例如我在D:\lib目錄中有ojdbc6.jar,想要將此檔案加入到local repository,所以執行指令:

mvn install:install-file -Dfile=D:\lib\ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar

但卻出現錯誤如下。

D:\workspace\demo>mvn install:install-file -Dfile=D:\lib\ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar
[INFO] Scanning for projects...
...
[INFO] --- maven-install-plugin:2.5.2:install-file (default-cli) @ demo ---
[ERROR] The specified file 'D:\devtool\ojdbc6.jar' not exists
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.454 s
[INFO] Finished at: 2020-09-17T11:19:55+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file (default-cli) on project
 demo: The specified file 'D:\devtool\ojdbc6.jar' not exists -> [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/MojoFailureException

最後想說是不是路徑不能用Windows的反斜線(backslash)\,所以把檔案路徑改成用正斜線(forward slash)/才安裝成功:

mvn install:install-file -Dfile=D:/lib/ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar
D:\workspace\demo>mvn install:install-file -Dfile=D:/lib/ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar
[INFO] Scanning for projects...
...
[INFO] --- maven-install-plugin:2.5.2:install-file (default-cli) @ demo ---
[INFO] pom.xml not found in ojdbc6.jar
[INFO] Installing D:\devtool\ojdbc6.jar to C:\Users\user\.m2\repository\com\oracle\ojdbc6\11.2.0.4\ojdbc6-11.2.0.4.
jar
[INFO] Installing C:\Users\user\AppData\Local\Temp\mvninstall7046334672898840349.pom to C:\Users\user\.m2\repos
itory\com\oracle\ojdbc6\11.2.0.4\ojdbc6-11.2.0.4.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.554 s
[INFO] Finished at: 2020-09-17T11:24:20+08:00
[INFO] ------------------------------------------------------------------------


沒有留言:

張貼留言