在使用 NetBeans 编译 Maven 项目时,我经常遇到以下错误:
无法执行目标 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(访问被拒绝)-> [帮助 1]
我不知道是什么原因造成的。解决方案是手动删除有问题的 .m2 内容,然后问题就解决了。但这很烦人。
谁有永久的解决方案?
编辑
[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
最佳答案
您的 -Dfile
参数中可能有错字。确保它指向实际的文件,而不是文件夹。
即确保你没有 -Dfile=C:\lib\jackson
当你的意思是 -Dfile=C:\lib\jackson.jar
以文件夹为目标可能会导致此“拒绝访问”错误,这对于实际问题似乎没有意义。
关于java - 无法执行目标...maven-install-plugin ...无法安装 Artifact ...(拒绝访问),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5798150/