无法执行目标... maven-install-plugin ... 无法安装工件...(访问被拒绝)
使用 NetBeans 编译 Maven 项目时,经常出现以下错误:
Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install (default-install) on project xxx: Failed安装工件 yyyy: C:\...\.m2\repository\...\yyyy-1.0.0.jar (访问被拒绝) -> [帮助1]
我不知道是什么原因造成的。解决方案是手动删除有问题的 .m2 内容,问题就解决了。但这很烦人。
有人有永久解决方案吗?
编辑
[错误]执行目标失败 org.apache.maven.plugins:maven-install-plugin:2.3.1:安装 Plasma 项目(默认安装): 安装工件失败 net.dwst:等离子:jar:1.0.0: C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar (访问被拒绝)-> [帮助1] org.apache.maven.lifecycle.LifecycleExecutionException: 未能执行目标 org.apache.maven.plugins:maven-install-plugin:2.3.1:安装 Plasma 项目(默认安装): 安装工件失败 net.dwst:等离子:jar:1.0.0: C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar (访问被拒绝)位于 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:203) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 在 org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 在 org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 在 org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316) 在 org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153) 在 org.apache.maven.cli.MavenCli.execute(MavenCli.java:451) 在 org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188) 在 org.apache.maven.cli.MavenCli.main(MavenCli.java:134) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native 方法)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke(Method.java:597) 在 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 在 org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 在 org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 在 org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 造成原因: org.apache.maven.plugin.MojoExecutionException: 安装工件失败 net.dwst:等离子:jar:1.0.0: C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar (访问被拒绝)位于 org.apache.maven.plugin.install.InstallMojo.execute(InstallMojo.java:139) 在 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195) ... 19 更多 原因: org.apache.maven.artifact.installer.ArtifactInstallationException: 安装工件失败 net.dwst:等离子:jar:1.0.0: C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar (访问被拒绝)位于 org.apache.maven.artifact.installer.DefaultArtifactInstaller.install(DefaultArtifactInstaller.java:110) 在 org.apache.maven.plugin.install.InstallMojo.execute(InstallMojo.java:103) ... 21 更多 原因: org.sonatype.aether.installation.InstallationException: 安装工件失败 net.dwst:等离子:jar:1.0.0: C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar (访问被拒绝)位于 org.sonatype.aether.impl.internal.DefaultInstaller.install(DefaultInstaller.java:279) 在 org.sonatype.aether.impl.internal.DefaultInstaller.install(DefaultInstaller.java:190) 在 org.sonatype.aether.impl.internal.DefaultRepositorySystem.install(DefaultRepositorySystem.java:322) 在 org.apache.maven.artifact.installer.DefaultArtifactInstaller.install(DefaultArtifactInstaller.java:106) ... 22 更多 原因: java.io.FileNotFoundException: C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar (访问被拒绝)位于 java.io.FileOutputStream.open(本机 方法)在 java.io.FileOutputStream。(FileOutputStream.java:179) 在 java.io.FileOutputStream。(FileOutputStream.java:131) 在 org.sonatype.aether.impl.internal.DefaultFileProcessor.copy(DefaultFileProcessor.java:120) 在 org.sonatype.aether.impl.internal.DefaultInstaller.install(DefaultInstaller.java:255) ... 25 个以上 [错误] [错误] [错误] 有关错误的更多信息 以及可能的解决方案,请阅读 以下文章:[错误] [帮助 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
I often getting the following error when compiling a maven project with NetBeans:
Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install (default-install) on project xxx: Failed to install artifact yyyy: C:\...\.m2\repository\...\yyyy-1.0.0.jar (Access is denied) -> [Help 1]
I don't know what is causing it. Solution is to erase the problematic .m2 content manually and the issue goes. But it is annoying.
Anyone has a permanent solution?
EDIT
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-install-plugin:2.3.1:install
(default-install) on project Plasma:
Failed to install artifact
net.dwst:Plasma:jar:1.0.0:
C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException:
Failed to execute goal
org.apache.maven.plugins:maven-install-plugin:2.3.1:install
(default-install) on project Plasma:
Failed to install artifact
net.dwst:Plasma:jar:1.0.0:
C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied) at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:203)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
at
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
at
org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)
at
org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)
at
org.apache.maven.cli.MavenCli.main(MavenCli.java:134)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at
java.lang.reflect.Method.invoke(Method.java:597)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by:
org.apache.maven.plugin.MojoExecutionException:
Failed to install artifact
net.dwst:Plasma:jar:1.0.0:
C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied) at
org.apache.maven.plugin.install.InstallMojo.execute(InstallMojo.java:139)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
... 19 more Caused by:
org.apache.maven.artifact.installer.ArtifactInstallationException:
Failed to install artifact
net.dwst:Plasma:jar:1.0.0:
C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied) at
org.apache.maven.artifact.installer.DefaultArtifactInstaller.install(DefaultArtifactInstaller.java:110)
at
org.apache.maven.plugin.install.InstallMojo.execute(InstallMojo.java:103)
... 21 more Caused by:
org.sonatype.aether.installation.InstallationException:
Failed to install artifact
net.dwst:Plasma:jar:1.0.0:
C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied) at
org.sonatype.aether.impl.internal.DefaultInstaller.install(DefaultInstaller.java:279)
at
org.sonatype.aether.impl.internal.DefaultInstaller.install(DefaultInstaller.java:190)
at
org.sonatype.aether.impl.internal.DefaultRepositorySystem.install(DefaultRepositorySystem.java:322)
at
org.apache.maven.artifact.installer.DefaultArtifactInstaller.install(DefaultArtifactInstaller.java:106)
... 22 more Caused by:
java.io.FileNotFoundException:
C:....m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied) at
java.io.FileOutputStream.open(Native
Method) at
java.io.FileOutputStream.(FileOutputStream.java:179)
at
java.io.FileOutputStream.(FileOutputStream.java:131)
at
org.sonatype.aether.impl.internal.DefaultFileProcessor.copy(DefaultFileProcessor.java:120)
at
org.sonatype.aether.impl.internal.DefaultInstaller.install(DefaultInstaller.java:255)
... 25 more [ERROR] [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/MojoExecutionException
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
您的
-Dfile
参数中可能有拼写错误。确保它指向实际的文件,而不是文件夹。即,当您的意思是
-Dfile=C:\lib\jackson.jar
时,确保您没有-Dfile=C:\lib\jackson
定位文件夹可能会导致这个“访问被拒绝”错误,这似乎对实际问题没有意义。
You may have a typo in your
-Dfile
argument. Make sure it's pointing to an actual file, not a folder.I.e. Make sure you don't have
-Dfile=C:\lib\jackson
when you mean-Dfile=C:\lib\jackson.jar
Targeting a folder can cause this "Access Denied" error, which doesn't seem to make sense for what the actual problem is.
此问题是在 NetBeans 崩溃后开始发生的。我最终删除了.m2的内容并从头开始重新安装NetBeans。问题消失了。我仍然不清楚是什么原因造成的,但它现在已经消失了。
This issue started to happen after a NetBeans crash. I finally deleted the content of .m2 and re-installed NetBeans from scratch. The issue disappeared. I am still unclear what would cause it, but it is now gone.
有时,当您执行 mvn clean 时,您应该检查是否打开了 /target 的文件夹或其他生成的资源,因此关闭所有这些文件夹可以解决问题。
Sometimes, when you do mvn clean, you should check if you have opened folders of /target, or other generated resources, so closing all those folders solves the issue.
我也遇到这个错误。我通过取消选中文件夹属性只读和隐藏来解决此问题。
I got this error too. I resolved this by unchecking the folder attributes read-only and Hidden.
我在 Eclipse Indigo SR2 中遇到过这个问题,我希望尝试一些比删除 .m2 更温和的方法。
我尝试取消选中“解决工作空间项目的依赖关系”,如 这篇文章,但继续收到消息。
我终于通过从命令行运行
mvn clean install
使其正常工作。I have experienced this problem in Eclipse Indigo SR2, and I was hoping to try something less drastic than deleting .m2.
I tried to uncheck "Resolve dependencies from Workspace projects" as described in this post, but continued to get the message.
I finally got it working by running
mvn clean install
from the command line.经过大约一个小时的挫折后,我解决了这个问题。
我已经升级了 Eclipse 环境,并使用 maven-install-plugin 添加了 2 个不在任何存储库中的 jar。这以前有效,但现在不行了。该插件每次运行构建时都会自动添加 jar。
我转到 .m2 文件夹并更改了它所抱怨的 .pom 文件的名称,然后,它创建了一个新文件并运行。显然文件夹结构存在权限问题。尝试一下!
After about an hour of frustration, here is how I fixed it.
I had upgraded my Eclipse environment and use the maven-install-plugin to add 2 jars that are not in any repository. This had worked previously but now it won't. This plugin automatically adds the jars each time it runs the build.
I went to the .m2 folder and changed the name of the .pom file it was complaining about and bam, it created a new one and ran. Obviously there was a permissions problem in the folder structure. Give it a try!
我也遇到这个错误,通过创建一个简单的maven项目解决了。
步骤:-
I got this error too, it was solved by creating a simple maven project.
Steps:-
由于某些原因(Windows 7),我没有权限访问指定的文件夹,因此您可以以管理员身份运行 Maven 或 IDE,或者尝试访问文件夹,您将看到弹出警告窗口,您必须单击“继续”才能永久访问此文件夹,这样您的用户帐户就会添加到该文件夹的 ACL 中,仅此而已!
for some reasons(windows 7) i don’t have permission to access the specified folder,so either you run the Maven or your IDE as administrator or so try to access the folder and you will have warning popup and you have to click Continue to permanently get access to this folder, so your user account is added to the ACL for the folder , and that's it !
我遇到了同样的问题,(对于基于Linux的用户)对我来说原因是它试图访问的文件夹具有root权限,所以任何普通用户都无法访问它。
要解决此问题,有两个步骤:
1. 在命令中添加 sudo
2. 删除项目的父文件夹(不是 .m2,与项目同名的文件夹),然后重试命令
i faced the same issue ,(for linux based users) the reason for me was the folder it was trying to access had root privilege , so any normal user could not access it.
to resolve this there are 2 steps :
1. add a sudo to the command
2. delete the parent folder for the project (not the .m2, folder with name same as the project) and then retry your command
该错误与 -Dfile 参数有关,因为它似乎不接受相对路径。提供绝对路径对我有用。
The error was related to the -Dfile parameter, as it seems to don't accept relative paths. Providing Absolute path worked for me.
只需以管理员身份运行 Netbeans 或任何 IDE、文本编辑器
Just run as administrator with Netbeans or any IDE,TextEditer