---
title: "maven Failed to copy file for artifact"
author: "wsjiang"
date: "2011-12-22T14:35:30Z"
tags: []
categories: ["互联网"]
slug: "maven-failed-to-copy-file-for-artifact"
draft: false
lastmod: "2012-07-03T19:13:05Z"
id: 1320821
url: "https://wsjiang.iteye.com/blog/1320821"
---

hile building project: maven install,maven package,maven war:inplace

在做项目过程中经常出现类似以下的错误，记下来备忘。

 

```
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.taobao.lifeuser:lifeuser-server:war:1.0.0-SNAPSHOT
[INFO] 
[INFO] Id: com.taobao.lifeuser:lifeuser-server:war:1.0.0-SNAPSHOT
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] No sources to compile
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory: E:\dev\workspace\lifeuser\lifeuser-server\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] [war:war]
[INFO] Packaging webapp
[INFO] Assembling webapp[lifeuser-server] in [E:\dev\workspace\lifeuser\lifeuser-server\target\lifeuser-server-1.0.0-SNAPSHOT]
[INFO] Processing war project
[ERROR] 

The following mojo encountered an error while executing:
Group-Id: org.apache.maven.plugins
Artifact-Id: maven-war-plugin
Version: 2.1-alpha-1
Mojo: war
brought in via: packaging: war

While building project:
Group-Id: com.taobao.lifeuser
Artifact-Id: lifeuser-server
Version: 1.0.0-SNAPSHOT
From file: E:\dev\workspace\lifeuser\lifeuser-server\pom.xml
Reason: Failed to copy file for artifact[com.taobao.lifeuser:lifeuser-core:jar:1.0.0-SNAPSHOT:compile]



[INFO] ------------------------------------------------------------------------
[INFO] For more information, run with the -e flag
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILED
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Thu Dec 22 14:22:50 CST 2011
[INFO] Final Memory: 2M/10M
[INFO] ------------------------------------------------------------------------
```

 

    Reason: Failed to copy file for artifact\[com.taobao.lifeuser:lifeuser-core:jar:1.0.0-SNAPSHOT:compile]

 

    错误原因：需要操作本次仓库中lifeuser-core.jar这个包，而在本地的workspace已经有一个lifeuser-core工程,此工程中也有一份lifeuser-core.jar包，导致出错.

 

    解决方案：先将lifeuser-core这工程关掉，然后再去maven war:inplace（install、package），就不会有问题了。