1

Spring アプリケーションに対する Maven を使用した単体テストの後にビルドを完了する際に問題が発生する。mvn のインストールが完了していないことに気付きました。すべての単体テストを実行した後、ハングしているように見えました。コマンドラインから実行するmvn installと、テストは完了しますが、ビルドがハングします

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

それで終わりです。2 つのスレッドが実行されています。そこで何をしたかわかりません。とにかく、トラブルシューティングのために、すべてのテストを削除し、プログラムを完全にビルドしました。を実行するmvn install -DskipTestsと、完了します。最後に、本質的に system.out.println("hello world"); である 1 つの JUnit テストを追加しました。JUnit アノテーション「@RunWith(SpringJUnit4ClassRunner.class)」をコメントアウトすることで、インストールでテストを実行し、インストールを完了することができました。Spring 3.1.0.RELEASE を使用しています。

ビルドに関するこの問題は、Windows7 の私の開発マシンからのものですが、Linux ベース (Ubuntu 11.10) です。Hudson CI サーバーは、同じ SVN リポジトリを使用して、1 時間ごとのビルドの同じプロジェクトで Maven インストールを正常に実行します。

4

2 に答える 2

1

おそらく、Spring Bean の 1 つがスレッドを生成しています。jconsole を使用してスタックしたプロセスに接続し、何がハングアップしているかを確認します。問題のある Bean で @PreDestroy を使用して、シャットダウン時にスレッドをキャンセルすることで修正できます。

于 2012-04-25T18:42:10.797 に答える
0

Spring アプリ コンテキストのシャットダウン中に、スレッド間で競合が発生しているようです。Spring フレームワークのデバッグ レベルのログを上げて、競合がどこにあるかを確認し、可能であればそれを排除してみてください。

アプリのコンテキストで問題がないように見える場合、別のオプションはプラグイン構成を調整することです。プラグインはテストのsurefire実行に使用され、複数のスレッドでテストを実行するオプションがあります。mvn with-Xを実行して、スレッド オプション (parallel、threadCount、perCoreThreadCount など) に使用されている値を確認することから始めます。Surefire プラグイン構成 (実行 ID は ) を微調整して、 1 つのスレッドのみが実行されていることを確認し、Windows 7 ボックスで動作default-testするかどうかを確認します。install

Windows で動作させると、現在の確実な構成 (スーパー POM によって提供されるデフォルトである可能性があります) が CI 環境で正常に動作します。したがって、プロファイルを作成し、Windows 7 環境で実行している場合はアクティブ化し、識別された確実なプラグイン構成をプロファイルに移動します。

于 2012-04-25T19:25:13.727 に答える