尝试使用 Maven 在本地存储库中安装 jar 时

When trying to install jar in local repository using maven

我的 Nexus Repo 中没有这个 SFTP jar,我已经将它的依赖项添加到 POM 文件中,但现在我想在我的本地存储库中安装这个 JAR,以便我可以在我的项目中使用它。但是,即使我以管理员权限打开命令提示符,访问权限也被拒绝。

 C:\Windows\system32>mvn install:install-file -DgroupId=org.springframework.integration -DartifactId=spring-integration-sftp -Dversion=4.1.5 -Dpackaging=jar -Dfile=C:\Repo
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom
---
[INFO] Installing C:\Repo to C:\Users\t868396\.m2\repository\org\springframework
\integration\spring-integration-sftp.1.5\spring-integration-sftp-4.1.5.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.827 s
[INFO] Finished at: 2015-06-23T11:02:52+05:00
[INFO] Final Memory: 15M/64M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4
:install-file (default-cli) on project standalone-pom: Error installing artifact
 'org.springframework.integration:spring-integration-sftp:jar': Failed to instal
l artifact org.springframework.integration:spring-integration-sftp:jar:4.1.5: C:
\Repo (Access is denied) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception

很可能 -Dfile=your.jar 不正确,请检查您的论点(仅供参考,您的帖子中省略了它)。

这是一个例子:

mvn install:install-file -DlocalRepositoryPath=repo -DcreateChecksum=true 
 -Dfile=[your-jar] -Dpackaging=jar 
 -DgroupId=[...] -DartifactId=[...] -Dversion=[...]

参见:Can I add jars to maven 2 build classpath without installing them?

并且:https://maven.apache.org/general.html#importing-jars