Java Maven 着色错误:访问被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23986331/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven Shading Error: Access is Denied
提问by PaulBGD
Now, I have already seen this question, however it doesn't appear anything is using my target folder.
现在,我已经看到了这个问题,但是似乎没有任何东西在使用我的目标文件夹。
What's going on, is when I compile it fails and shows me this error:
发生了什么,当我编译失败并向我显示此错误时:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project FooProject: Error creating shaded jar: Failed to analyze class dependencies: C:\Users\paul_000\Documents\FooCore\target\classes (Access is denied) -> [Help 1]
I'm not quite sure exactly why this happens, as it doesn't happen on my normal computer.
我不太确定为什么会发生这种情况,因为它不会发生在我的普通计算机上。
EDIT: I forgot to mention, the jar I am shading does not exist on a repository. I just compile it locally (clean install). As well, here's what I use to shade:
编辑:我忘了提到,我正在着色的 jar 在存储库中不存在。我只是在本地编译它(全新安装)。同样,这是我用来着色的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
</configuration>
</execution>
</executions>
</plugin>
采纳答案by Stephan
You can face this error, if you're compiling from Eclipse with m2e plugin.
如果您使用 m2e 插件从 Eclipse 编译,您可能会遇到此错误。
The workaround is to uncheck Resolve Workspace artifacts
in the Maven Run Configuration.
解决方法是取消选中Resolve Workspace artifacts
Maven 运行配置。
回答by dfritch
I am using Eclipse Spring with the maven plugin. I was seeing a similar error in the logs:
我正在使用带有 Maven 插件的 Eclipse Spring。我在日志中看到了类似的错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project lds_ws_framework: Error creating shaded jar: C:\Users\fritchd\Documents\autoaction_archivetkitproject\target\classes (Access is denied) -> [Help 1]
[错误] 无法在项目 lds_ws_framework 上执行目标 org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default): Error creation shaded jar: C:\Users\fritchd\Documents\autoaction_archivetkitproject\target\classes (访问被拒绝)-> [帮助 1]
I had recently updated my projects to use the maven-shade-plugin 2.3 from a different maven build process. I noticed I had a lot of artifacts from the previous process in the \target folder. So I tried just deleting all files under the \target directory for that project. When I reran the build, I didn't see the error.
我最近更新了我的项目,以使用来自不同 maven 构建过程的 maven-shade-plugin 2.3。我注意到我在 \target 文件夹中有很多来自上一个过程的工件。所以我尝试删除该项目的 \target 目录下的所有文件。当我重新运行构建时,我没有看到错误。
回答by user1903994
Use the artifactSet option of maven-shade-plugin
使用 maven-shade-plugin 的 artifactSet 选项
For whatever reason this way Eclipse does not produce the "Access Denied" error
无论出于何种原因,Eclipse 都不会产生“拒绝访问”错误
回答by Springrbua
I had a similar issue and as this is the first question that shows up on google, I add my solution as an answer here.
In my case, the problem was related to the dependencyReducedPomLocation
I've set.
I wanted to move the dependency-reduced-pom
to the target
folder and so I've set the property to ${project.build.directory}
.
However, this property does not expect a folder, but a file and the correct value for it would be ${project.build.directory}${file.separator}dependency-reduced-pom.xml
.
After this change everything worked as expected.
我有一个类似的问题,因为这是谷歌上出现的第一个问题,我在这里添加我的解决方案作为答案。
就我而言,问题与dependencyReducedPomLocation
我设置的有关。
我想将 移动dependency-reduced-pom
到target
文件夹,所以我已将属性设置为${project.build.directory}
.
但是,此属性不需要文件夹,而是需要文件,并且它的正确值是${project.build.directory}${file.separator}dependency-reduced-pom.xml
.
在此更改后,一切都按预期工作。