Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven在运行Spring JUnit测试后挂起_Spring_Maven_Junit - Fatal编程技术网

Maven在运行Spring JUnit测试后挂起

Maven在运行Spring JUnit测试后挂起,spring,maven,junit,Spring,Maven,Junit,在针对Spring应用程序使用maven进行单元测试后,在完成构建时遇到问题。我注意到mvn安装没有完成,在运行了所有单元测试之后,它似乎挂起了。如果运行mvn install我将从cmd行获得要完成的测试,但是构建挂起 Results : Tests run: 34, Failures: 0, Errors: 0, Skipped: 0 14:20:15,588 [Thread-3] INFO GenericApplicationContext - Closing org.spring

在针对Spring应用程序使用maven进行单元测试后,在完成构建时遇到问题。我注意到mvn安装没有完成,在运行了所有单元测试之后,它似乎挂起了。如果运行
mvn install
我将从cmd行获得要完成的测试,但是构建挂起

Results :

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

14:20:15,588 [Thread-3] INFO  GenericApplicationContext  - Closing org.springframework.context.support.GenericApplicationContext@10a3b24: startup date [Wed Apr 25 14:20:08 EDT 2012]; root of context hierarchy
14:20:15,589 [Thread-3] INFO  DefaultListableBeanFactory  - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@16c163f: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,sysModel,alarmList,resourcePool,sysParams,stationHelper,commandTracker,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
14:20:15,595 [Thread-7] INFO  GenericApplicationContext  - Closing org.springframework.context.support.GenericApplicationContext@c5577c: startup date [Wed Apr 25 14:20:10 EDT 2012]; root of context hierarchy
14:20:15,596 [Thread-7] INFO  DefaultListableBeanFactory  - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@10952e8: defining beans [alarmDao,purgeDao,xactionDao,dataSource,sysModel,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
到此为止。两个线程正在运行,不确定我在那里做了什么。无论如何,为了排除故障,我删除了所有的测试,并完全构建了程序。如果我运行
mvn安装-DskipTests
,我就可以完成它。最后,我添加了一个JUnit测试,它本质上是一个system.out.println(“hello world”);。我可以通过注释JUnit注释“@RunWith(SpringJUnit4ClassRunner.class)”,让安装运行测试并完成安装。我正在使用Spring3.1.0.RELEASE


这个构建的问题来自于我在Windows7上的开发机器,但是我们的基于Linux(Ubuntu11.10)。Hudson CI server使用相同的SVN存储库在同一项目上成功运行Maven install,每小时进行一次构建

您的一个Spring bean可能正在生成线程。使用jconsole连接到卡住的进程并查看挂起的是什么。您可以通过在有问题的bean上使用@PreDestroy在关闭时取消线程来修复它。

可能您的一个Spring bean正在生成线程。使用jconsole连接到卡住的进程并查看挂起的是什么。您可以通过在有问题的bean上使用@PreDestroy在关闭时取消线程来修复它。

在Spring应用程序上下文关闭期间,线程之间似乎存在一些争用。您可以尝试打开Spring框架调试级别的日志记录,以查看争用的位置,如果可以,可以消除争用

如果在应用程序上下文中似乎没有问题,另一个选项是调整插件配置。
surefire
插件用于执行测试,它具有在多个线程中运行测试的选项。首先用
-X
运行mvn,查看线程选项(parallel、threadCount、perCoreThreadCount等)使用了哪些值。调整surefire插件配置(执行ID为
默认测试
),以确保只有一个线程正在执行,并查看是否可以在Windows 7上运行
安装


一旦在Windows中工作:当前的surefire配置(可能是super POM提供的默认配置)在CI环境中工作正常。因此,我将创建一个,并将已识别的surefire插件配置移动到配置文件中。

在Spring应用程序上下文关闭期间,线程之间似乎存在一些争用。您可以尝试打开Spring框架调试级别的日志记录,以查看争用的位置,如果可以,可以消除争用

如果在应用程序上下文中似乎没有问题,另一个选项是调整插件配置。
surefire
插件用于执行测试,它具有在多个线程中运行测试的选项。首先用
-X
运行mvn,查看线程选项(parallel、threadCount、perCoreThreadCount等)使用了哪些值。调整surefire插件配置(执行ID为
默认测试
),以确保只有一个线程正在执行,并查看是否可以在Windows 7上运行
安装


一旦在Windows中工作:当前的surefire配置(可能是super POM提供的默认配置)在CI环境中工作正常。因此,我将创建一个,并将已识别的surefire插件配置移动到配置文件中。

是的,检查您是否正在手动创建线程,或者是否正在使用@Asynchronous或Spring的计时器/执行器代码。是的,检查您是否正在手动创建线程,或者是否正在使用@Asynchronous或Spring的计时器/执行器代码。