maven-resources-plugin:2.5-无法创建资源输出目录 [英] maven-resources-plugin:2.5 - Cannot create resource output directory
问题描述
我偶尔使用此项目构建项目时会收到此错误
I occasionally receive this error when I build my project with
>mvn --version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 15:51:28+0200)
Maven home: ...\apache-maven-3.0.5
Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
Java home: ...
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
和错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources
(default-resources) on project project-name: Cannot create resource output directory:
path\to\project\code\project-name\target\classes -> [Help 1]
注意:有时会发生这种情况,并且与代码无关.可以在完全相同的源代码的两个连续构建之一中进行-一个接一个地进行.
Note: this happens sometimes, and it is not related to the code. It can happen in one of two consecutive builds - one after the other, against exactly the same source code.
有人知道如何完全避免它吗?它往往会中断相当耗时的构建:-/
Does anyone have any idea how to avoid it completely? It tends to interrupt quite a time-consuming build :-/
推荐答案
在Windows上,无法创建文件夹的原因有:
On Windows, there reasons for being unable to create a folder are:
- 其他一些过程正在同时删除此文件夹
- 您没有访问此文件夹的权限
- 该文件夹位于网络共享上
众所周知,Windows上的网络共享不可靠.不要将它们用于任何自动化任务.始终在构建项目时将所有文件都驻留在本地硬盘上.
Network shares are notoriously unreliable on Windows. Don't use them for any automated tasks. Always build projects with all files residing on a local hard disk.
如果同时使用Maven和Eclipse进行构建,则应将它们配置为使用不同的目标文件夹.参见 https://stackoverflow.com/a/54366009/34088
If you use Maven and Eclipse to build at the same time, you should configure them to use different target folders. See https://stackoverflow.com/a/54366009/34088
您的POM应该如下所示:
Your POM should look like this:
<project>
...
<build>
<outputDirectory>${basedir}/${target.dir}/classes</outputDirectory>
<testOutputDirectory>${basedir}/${target.dir}/test-classes</testOutputDirectory>
</build>
<properties>
<target.dir>target</target.dir>
</properties>
<profiles>
<profile>
<id>eclipse-folders</id>
<properties>
<target.dir>target-eclipse</target.dir>
</properties>
</profile>
</profiles>
...
剩下的就是在IDE中启用配置文件eclipse-folders
.
All that's left is to enable the profile eclipse-folders
in the IDE.
这篇关于maven-resources-plugin:2.5-无法创建资源输出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!