Java Maven 无法执行目标 org.apache.maven.plugins:maven-clean-plugin:2.5:clean 无法删除 access_log
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28649509/
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 Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean Failed to delete access_log
提问by marknorkin
I'm trying to run simple struts project using maven and tomcat.
我正在尝试使用 maven 和 tomcat 运行简单的 struts 项目。
When I'm trying to exucute next goals: clean install tomcat7:run
I'm getting MojoExecutionException
:
当我试图执行下一个目标时:clean install tomcat7:run
我得到MojoExecutionException
:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean
(default-clean) on project myproject: Failed to clean project: Failed to delete
D:\EclipseWorkspace\myproject\target\tomcat\logs\access_log.2015-02-21
-> [Help 1]
I've googled and understand that tomcat uses this access_log
file, where he logs user requests. And by the time when I want to execute goals listed above, as I'm using Eclipse IDE, the JVM denies for deleting this file.
我用谷歌搜索并了解到 tomcat 使用这个access_log
文件,他在其中记录用户请求。当我想要执行上面列出的目标时,因为我使用的是 Eclipse IDE,JVM 拒绝删除这个文件。
I saw same questions: Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1, Maven - Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean.
我看到了同样的问题:Failed to execute target org.apache.maven.plugins:maven-clean-plugin:2.4.1,Maven - Failed to execute target org.apache.maven.plugins:maven-clean-plugin:2.4.1 :干净。
But don't understand the proposed solutions to such problem.
但不了解针对此类问题的建议解决方案。
采纳答案by Michael Peacock
I've seen this sort of error whenever there's a process that's holding a lock on a file in some subfolder that Maven is trying to clean. Check that your Tomcat instance is really stopped (look for java processes in Task Manager that shouldn't be there). I've also created this issue for myself by opening the access log in a text editor, and then forgetting to close the editor after shutting down the Tomcat and trying to run a new build.
每当有一个进程锁定 Maven 试图清理的某个子文件夹中的文件时,我都会看到这种错误。检查您的 Tomcat 实例是否真的停止(在任务管理器中查找不应该存在的 java 进程)。我也通过在文本编辑器中打开访问日志为自己创建了这个问题,然后在关闭 Tomcat 并尝试运行新构建后忘记关闭编辑器。
回答by marknorkin
Micahel Peacockand khmarbaisewere right about some proccess is blocking the deletion.
Micahel Peacock和khmarbaise关于某些过程阻止删除是正确的。
This is some tip for maven newbies, like me.
这是给像我这样的 Maven 新手的一些提示。
I've faced such problem, because after running Tomcat
with maven goals clean install tomcat7:run
I stopped it either through shutdown
batch file in ${CATALINA_HOME}/bin
directory or through installed Eclipse Tomcat plugin by clicking on the next label:
我遇到过这样的问题,因为在Tomcat
使用 maven 目标运行后,clean install tomcat7:run
我通过目录中的shutdown
批处理文件${CATALINA_HOME}/bin
或通过单击下一个标签通过安装的 Eclipse Tomcat 插件停止了它:
But to do it in the right way you should click on stop label in console view:
但是要以正确的方式执行此操作,您应该单击控制台视图中的停止标签:
Then locale tomcat instance will be stopped and no such errors would appears, because proccess will shutdown gracefully.
然后 locale tomcat 实例将被停止并且不会出现此类错误,因为 proccess 将正常关闭。
回答by Vivek Jain
Just close your command prompt and again run it as Administrator and after that fire your maven command i.e. mvn clean , then it would work fine :)
只需关闭您的命令提示符并再次以管理员身份运行它,然后启动您的 maven 命令,即 mvn clean ,然后它就可以正常工作了:)
回答by mohsen.nour
I had the same problem in Fedora. In my case owner of targe directory was changed to root usring --> [chown your-username target] I fix it.
我在 Fedora 中遇到了同样的问题。在我的情况下,目标目录的所有者已更改为 root 用户 --> [chown your-username target] 我修复了它。