Spring Initializr错误:无法删除临时目录

时间:2019-03-13 03:46:16

标签: java spring spring-io initializr

当我试图从源代码构建它来运行自己的Spring Initialzr实例时,执行测试时临时文件出现了问题。

Windows10 java8

  

mvnw全新安装

  

cd initializr-generator |   mvn全新安装

[ERROR] Tests run: 12, Failures: 0, Errors: 12, Skipped: 0, Time elapsed: 2.832 s <<< FAILURE! - in io.spring.initializr.generator.language.groovy.GroovySourceCodeWriterTests
    [ERROR] annotationWithOnlyValueAttribute  Time elapsed: 0.297 s  <<< ERROR!
    java.io.IOException: Failed to delete temp directory C:\Users\23804\AppData\Local\Temp\junit6336200348962192500. The following paths could not be deleted (see suppressed exceptions for details): , project-3413258039486290770, project-3413258039486290770\com, project-3413258039486290770\com\example, project-3413258039486290770\com\example\Test.groovy

所有项目均从https://github.com/spring-io/initializr克隆。

GroovySourceCodeWriterTests发生错误。 一些错误信息:

[INFO] Running io.spring.initializr.generator.language.groovy.GroovySourceCodeWriterTests
?? 13, 2019 12:24:31 ?? org.junit.jupiter.engine.execution.JupiterEngineExecutionContext close
??: Caught exception while closing extension context: org.junit.jupiter.engine.descriptor.MethodExtensionContext@282308c3
java.io.IOException: Failed to delete temp directory C:\Users\23804\AppData\Local\Temp\junit1110237848291057055. The following paths could not be deleted (see suppressed exceptions for details): , project-4269346244166458901, project-4269346244166458901\com, project-4269346244166458901\com\example, project-4269346244166458901\com\example\Test.groovy
        at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.createIOExceptionWithAttachedFailures(TempDirectory.java:206)
        at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.close(TempDirectory.java:167)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.jupiter.engine.execution.ExtensionValuesStore.closeAllStoredCloseableValues(ExtensionValuesStore.java:61)
        at org.junit.jupiter.engine.descriptor.AbstractExtensionContext.close(AbstractExtensionContext.java:73)
        at org.junit.jupiter.engine.execution.JupiterEngineExecutionContext.close(JupiterEngineExecutionContext.java:53)
        at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.cleanUp(JupiterTestDescriptor.java:191)
        at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.cleanUp(JupiterTestDescriptor.java:54)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$cleanUp$9(NodeTestTask.java:151)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.cleanUp(NodeTestTask.java:151)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:83)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
        at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
        at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:142)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:117)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
        Suppressed: java.nio.file.DirectoryNotEmptyException: C:\Users\23804\AppData\Local\Temp\junit1110237848291057055
                at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:266)
                at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
                at java.nio.file.Files.delete(Files.java:1126)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.deleteAndContinue(TempDirectory.java:187)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.postVisitDirectory(TempDirectory.java:182)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.postVisitDirectory(TempDirectory.java:173)
                at java.nio.file.Files.walkFileTree(Files.java:2688)
                at java.nio.file.Files.walkFileTree(Files.java:2742)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.deleteAllFilesAndDirectories(TempDirectory.java:173)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.close(TempDirectory.java:165)
                ... 44 more
        Suppressed: java.nio.file.DirectoryNotEmptyException: C:\Users\23804\AppData\Local\Temp\junit1110237848291057055\project-4269346244166458901
                at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:266)
                at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
                at java.nio.file.Files.delete(Files.java:1126)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.deleteAndContinue(TempDirectory.java:187)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.postVisitDirectory(TempDirectory.java:182)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.postVisitDirectory(TempDirectory.java:173)
                at java.nio.file.Files.walkFileTree(Files.java:2688)
                at java.nio.file.Files.walkFileTree(Files.java:2742)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.deleteAllFilesAndDirectories(TempDirectory.java:173)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.close(TempDirectory.java:165)
                ... 44 more
        Suppressed: java.nio.file.DirectoryNotEmptyException: C:\Users\23804\AppData\Local\Temp\junit1110237848291057055\project-4269346244166458901\com
                at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:266)
                at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
                at java.nio.file.Files.delete(Files.java:1126)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.deleteAndContinue(TempDirectory.java:187)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.postVisitDirectory(TempDirectory.java:182)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.postVisitDirectory(TempDirectory.java:173)
                at java.nio.file.Files.walkFileTree(Files.java:2688)
                at java.nio.file.Files.walkFileTree(Files.java:2742)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.deleteAllFilesAndDirectories(TempDirectory.java:173)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.close(TempDirectory.java:165)
                ... 44 more
        Suppressed: java.nio.file.DirectoryNotEmptyException: C:\Users\23804\AppData\Local\Temp\junit1110237848291057055\project-4269346244166458901\com\example
                at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:266)
                at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
                at java.nio.file.Files.delete(Files.java:1126)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.deleteAndContinue(TempDirectory.java:187)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.postVisitDirectory(TempDirectory.java:182)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.postVisitDirectory(TempDirectory.java:173)
                at java.nio.file.Files.walkFileTree(Files.java:2688)
                at java.nio.file.Files.walkFileTree(Files.java:2742)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.deleteAllFilesAndDirectories(TempDirectory.java:173)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.close(TempDirectory.java:165)
                ... 44 more
        Suppressed: java.nio.file.FileSystemException: C:\Users\23804\AppData\Local\Temp\junit1110237848291057055\project-4269346244166458901\com\example\Test.groovy: ????????????????????

                at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
                at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
                at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
                at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
                at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
                at java.nio.file.Files.delete(Files.java:1126)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.deleteAndContinue(TempDirectory.java:187)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.visitFile(TempDirectory.java:177)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath$1.visitFile(TempDirectory.java:173)
                at java.nio.file.Files.walkFileTree(Files.java:2670)
                at java.nio.file.Files.walkFileTree(Files.java:2742)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.deleteAllFilesAndDirectories(TempDirectory.java:173)
                at org.junit.jupiter.engine.extension.TempDirectory$CloseablePath.close(TempDirectory.java:165)
                ... 44 more

?? 13, 2019 12:24:31 ?? org.junit.jupiter.engine.execution.JupiterEngineExecutionContext close

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,我找到了答案: “经过进一步检查,树中的任何只读目录都将导致清理失败。” 此处:https://www.gitmemory.com/issue/junit-team/junit5/2171/582494859

那帮助了我。 在测试结束时,我从目录中删除了只读访问权限,并且不再发生错误。

如果在测试结束时清理临时目录,这可能会有所帮助。