Java 专家未能清理项目:未能删除..\org.ow2.util.asm-asm-tree-3.1.jar
我使用STS(springtoolsuite)+maven插件 每次使用Java 专家未能清理项目:未能删除..\org.ow2.util.asm-asm-tree-3.1.jar,java,eclipse,spring,maven,spring-tool-suite,Java,Eclipse,Spring,Maven,Spring Tool Suite,我使用STS(springtoolsuite)+maven插件 每次使用maven clean运行应用程序时,我都会看到以下错误: [INFO] Scanning for projects... [INFO] [INFO] -----------------------------------------------------------------
maven clean
运行应用程序时,我都会看到以下错误:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hhsystem ui 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ ui ---
[INFO] Deleting C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.471s
[INFO] Finished at: Mon Oct 21 12:34:33 MSK 2013
[INFO] Final Memory: 2M/90M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project ui: Failed to clean project: Failed to delete C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target\org.ow2.util.asm-asm-tree-3.1.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
我必须关闭STS并转到C:\Users\Nikolay\u Tkachev\workspace\HHSystem\UI\target
并删除org.ow2.util.asm-asm-tree-3.1.jar
再次启动STS后,它可以工作,但这是一个麻烦
你能帮我解决这个问题吗
更新为卡拉托基L 我从此状态运行
maven clean
:
我在命令行中看到了与eclipse插件相同的行为
如果我在STS运行时观看unlocker,我会看到
:在开始清理之前停止服务器 停止服务器 您可以从Servers视图停止服务器 要停止服务器,请执行以下操作:
来源:Eclipse帮助您的问题是,当您执行
mvn clean
命令时,STS中正在运行的进程正在使用目标目录中的文件。Maven将无法删除这些文件(因为其他进程仍在访问它们),因此会因该错误而失败
在运行Maven控制台命令之前,尝试停止STS中的所有进程(测试、服务器、应用程序)。注意:如果STS正在清理项目,从而重新编译源代码,而不是运行进程,则也可能出现这种行为。摘要:使用外部脚本(批处理文件),该脚本a)停止服务器,b)在运行maven clean之前解锁.jar文件 步骤:
unlock\u handles.bat
句柄-c
和句柄-p
在这里很有用好的,这里有一个粗略的、概念验证版的unlock_handles.bat供您试用:
REM "Use handle.exe to figure out the process id and handle ids, parse the output, then close the handle (again using handle.exe)"
cd "C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target"
"c:/Program Files/Process Explorer/handle.exe" -p java.exe "C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target" > handles.txt
@echo "O====== Going to unlock all the below file handles! =======O"
FOR /F "tokens=1-26 delims=: " %a in (handles.txt) DO @echo %h
FOR /F "tokens=1-26 delims=: " %a in (handles.txt) DO handle -p %c -c %f -y
当然,在尝试之前,您必须更改Sysinternals的handle.exe路径。对于linux用户:可能的解决方案。 如果仅向root用户而不是普通用户提供了删除访问权限,则会发生由于“未能删除<任何文件或文件夹>”而导致的生成错误 修复:键入ll命令以列出无法删除的文件,如果该文件具有root访问权限,请通过以下方式更改为普通用户: sudo chown-R用户名:用户名文件名
稍后尝试maven clean and build。如果锁定
org.ow2.util.asm-asm-tree-3.1.jar
并启动eclipse,日志显示谁无法锁定文件。无法锁定文件的同一代码行不会解除锁定。您也可以尝试尝试-Dmaven.clean.failOnError=false
(来自)在预清洁阶段I,使用Maven Unlocker程序执行。此程序为任何程序解锁所有文件和目录 我使用maven antrun插件执行此操作,并且仅在windows系统中执行
<profile>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>pre-clean</phase>
<configuration>
<tasks>
<exec dir="${project.build.directory}" executable="cmd" failonerror="false">
<arg value="Unlocker.exe" />
<arg value="/S" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
窗户
maven antrun插件
1.8
预清洁
跑
尝试禁用Project->自动生成
正如Scorpio所建议的,有一个进程正在运行,它在某个地方锁定了一个文件
我有一个大型多模块maven项目,经常在clean上失败,这为我解决了这个问题。
完成后,我会自动重新启用构建。我也遇到类似问题。早些时候,我使用Maven 3构建项目。在切换到maven 2之后,我出现了上述错误
通过切换到Maven 3解决了这个问题。我也有同样的问题,这个
mvn clean install -U
命令修复了错误。可能有许多进程使用编译的源代码,可能是服务器、旧maven指令或IDE。确保终止所有进程,停止服务器,然后再次执行maven。如果问题仍然存在,则应关闭java.exe进程
问候 关闭目标文件夹及其在mvn clean之前打开的文件如果您对目标文件夹没有管理员权限,Maven会投诉。检查您是否有管理员权限删除该文件夹
删除任务管理器中的java.exe进程并运行mvn clean install。它对我有效。如果所有步骤(在现有答案中)都不起作用,只需关闭eclipse,然后再次打开eclipse。我通过以下操作解决了我的问题:
- mvn清洁
- mvn安装
-
mvn install mvn clean install