gpt4 book ai didi

java - Maven测试挂起

转载 作者:行者123 更新时间:2023-12-02 07:53:45 25 4
gpt4 key购买 nike

我在从 Maven 运行单元测试时遇到了一个奇怪的问题。我有一组单元测试,如果逐个运行,它们可以完美运行。然而,当我从 Maven(mvn 测试)运行它们时,它会挂起(永远阻塞)。

它始终卡在该测试使用的 A 类中的同一点(同一测试类)。我尝试从 A.class 中删除日志创建,测试开始成功运行。这是行:

private static final Logger log = LoggerFactory.getLogger(A.class);

这是线程转储:

"main" prio=6 tid=0x00446c00 nid=0x1278 runnable [0x00a2f000]
java.lang.Thread.State: RUNNABLE
at java.lang.ProcessImpl.waitFor(Native Method)
at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:173)
at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:114)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:231)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.runSuitesForkOnce(ForkStarter.java:125)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:109)
at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:619)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

我不知道从这里该去哪里。欢迎提出任何建议。

最佳答案

可能是资源死锁?鉴于有关另一个 Maven 进程正在生成的评论,这可能表明该去哪里。您可以尝试将同步放在测试中的某处(或所有方法上),看看它是否消失。如果是这样,则可能是死锁。

关于java - Maven测试挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9807062/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com