maven-resources-plugin:2.5 - 无法创建资源输出目录

时间:2022-06-17 22:49:07

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"

and the error:

和错误:

[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 :-/

有没有人知道如何完全避免它?它往往会中断相当耗时的构建: - /

5 个解决方案

#1


14  

On Windows, there reasons for being unable to create a folder are:

在Windows上,无法创建文件夹的原因是:

  1. Some other process is deleting this folder at the same time
  2. 其他一些进程正在同时删除此文件夹
  3. You don't have permissions to access this folder
  4. 您无权访问此文件夹
  5. The folder is on a network share
  6. 该文件夹位于网络共享上

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.

在Windows上,网络共享是出了名的不可靠。不要将它们用于任何自动化任务。始终使用驻留在本地硬盘上的所有文件构建项目。

If you use Maven and Eclipse to build at the same time, you should configure them to use different target folders. See http://www.jroller.com/eu/entry/configuring_separate_maven_output_folders

如果您同时使用Maven和Eclipse进行构建,则应将它们配置为使用不同的目标文件夹。请参阅http://www.jroller.com/eu/entry/configuring_separate_maven_output_folders

Your POM should look like this:

你的POM应该是这样的:

<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>
  ...  

All that's left is to enable the profile eclipse-folders in the IDE.

剩下的就是在IDE中启用配置文件eclipse-folders。

#2


6  

Disable the automatic build of your IDE (Eclipse or IntellJ IDEA or whatever). It will conflict with the Maven build.

禁用IDE的自动构建(Eclipse或IntellJ IDEA或其他)。它将与Maven构建冲突。

#3


0  

I had the exact same issue when trying to run the First Cup tutorial.

在尝试运行First Cup教程时,我遇到了完全相同的问题。

I fixed it by simply closing NetBeans and running it as administrator (via right click).

我通过简单地关闭NetBeans并以管理员身份运行它来修复它(通过右键单击)。

#4


0  

For me the reason for this was only being in said folder with my git bash while building. Ensure that you don't happen to have the said folder open in any other program.

对我来说,这个的原因只是在构建时使用我的git bash在所述文件夹中。确保您没有碰巧在任何其他程序中打开所述文件夹。

#5


0  

My issue was resolved when I gave mvn clean command from windows coammandprompt

当我从windows coammandprompt提供mvn clean命令时,我的问题得到了解决

#1


14  

On Windows, there reasons for being unable to create a folder are:

在Windows上,无法创建文件夹的原因是:

  1. Some other process is deleting this folder at the same time
  2. 其他一些进程正在同时删除此文件夹
  3. You don't have permissions to access this folder
  4. 您无权访问此文件夹
  5. The folder is on a network share
  6. 该文件夹位于网络共享上

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.

在Windows上,网络共享是出了名的不可靠。不要将它们用于任何自动化任务。始终使用驻留在本地硬盘上的所有文件构建项目。

If you use Maven and Eclipse to build at the same time, you should configure them to use different target folders. See http://www.jroller.com/eu/entry/configuring_separate_maven_output_folders

如果您同时使用Maven和Eclipse进行构建,则应将它们配置为使用不同的目标文件夹。请参阅http://www.jroller.com/eu/entry/configuring_separate_maven_output_folders

Your POM should look like this:

你的POM应该是这样的:

<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>
  ...  

All that's left is to enable the profile eclipse-folders in the IDE.

剩下的就是在IDE中启用配置文件eclipse-folders。

#2


6  

Disable the automatic build of your IDE (Eclipse or IntellJ IDEA or whatever). It will conflict with the Maven build.

禁用IDE的自动构建(Eclipse或IntellJ IDEA或其他)。它将与Maven构建冲突。

#3


0  

I had the exact same issue when trying to run the First Cup tutorial.

在尝试运行First Cup教程时,我遇到了完全相同的问题。

I fixed it by simply closing NetBeans and running it as administrator (via right click).

我通过简单地关闭NetBeans并以管理员身份运行它来修复它(通过右键单击)。

#4


0  

For me the reason for this was only being in said folder with my git bash while building. Ensure that you don't happen to have the said folder open in any other program.

对我来说,这个的原因只是在构建时使用我的git bash在所述文件夹中。确保您没有碰巧在任何其他程序中打开所述文件夹。

#5


0  

My issue was resolved when I gave mvn clean command from windows coammandprompt

当我从windows coammandprompt提供mvn clean命令时,我的问题得到了解决