0

私は春のアプリケーションを持っています。使用すると異なる動作が見られます

1 -

次のように実行 -> jUnit テスト

申請時に

それは良い作品です。

2-

次のように実行 -> Maven テスト

確かなレポートでは、非常に長いトレースが表示されます。その原因:

java.lang.NoClassDefFoundError: Lcom/epam/hhsystem/util/DatabaseHelper;

どの構成がmavenを使用しているかを知るにはどうすればよいですか?

Spring Tool Suitで開発

アップデート

私が試したら

Project -> Clean

以降

mvn clean test私が見るcmdから

C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI>mvn clean test
[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] --- maven-resources-plugin:2.5:resources (default-resources) @ ui ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1251 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ ui ---
[WARNING] File encoding has not been set, using platform encoding Cp1251, i.e. build is platform dependent!
[INFO] Compiling 11 source files to C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] bad path element "": no such file or directory
C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\MyContextListener.java:[8,29]
 cannot find symbol
symbol  : class DatabaseHelper
location: package com.epam.hhsystem.util
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\MyContextListener.jav
a:[12,1] cannot find symbol
symbol  : class DatabaseHelper
location: class com.epam.hhsystem.web.controllers.MyContextListener
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\MyApplicationListener
.java:[10,29] cannot find symbol
symbol  : class DatabaseHelper
location: package com.epam.hhsystem.util
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\MyApplicationListener
.java:[16,1] cannot find symbol
symbol  : class DatabaseHelper
location: class com.epam.hhsystem.web.controllers.MyApplicationListener
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\ApplicationWebListene
r.java:[9,29] cannot find symbol
symbol  : class DatabaseHelper
location: package com.epam.hhsystem.util
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\ApplicationWebListene
r.java:[14,1] cannot find symbol
symbol  : class DatabaseHelper
location: class com.epam.hhsystem.web.controllers.ApplicationWebListener
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[12,23] package org.apache.log4j does not exist
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[24,16] cannot find symbol
symbol  : class Logger
location: class com.epam.hhsystem.web.controllers.CustomAuthentificationProvider
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\AbstractController.ja
va:[49,20] cannot find symbol
symbol  : method getAllSkills()
location: class com.epam.hhsystem.services.UtilService
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[24,32] cannot find symbol
symbol  : variable Logger
location: class com.epam.hhsystem.web.controllers.CustomAuthentificationProvider
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[59,17] [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[63,17] [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[64,17] [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[65,17] [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[66,17] [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\VacancyMenuController
.java:[79,20] cannot find symbol
symbol  : method getAllSkills()
location: class com.epam.hhsystem.services.UtilService
[INFO] 16 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.059s
[INFO] Finished at: Wed Oct 23 18:52:14 MSK 2013
[INFO] Final Memory: 21M/162M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project ui:
 Compilation failure: Compilation failure:
[ERROR] bad path element "": no such file or directory
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\MyContextListener.jav
a:[8,29] cannot find symbol
[ERROR] symbol  : class DatabaseHelper
[ERROR] location: package com.epam.hhsystem.util
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\MyContextListener.jav
a:[12,1] cannot find symbol
[ERROR] symbol  : class DatabaseHelper
[ERROR] location: class com.epam.hhsystem.web.controllers.MyContextListener
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\MyApplicationListener
.java:[10,29] cannot find symbol
[ERROR] symbol  : class DatabaseHelper
[ERROR] location: package com.epam.hhsystem.util
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\MyApplicationListener
.java:[16,1] cannot find symbol
[ERROR] symbol  : class DatabaseHelper
[ERROR] location: class com.epam.hhsystem.web.controllers.MyApplicationListener
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\ApplicationWebListene
r.java:[9,29] cannot find symbol
[ERROR] symbol  : class DatabaseHelper
[ERROR] location: package com.epam.hhsystem.util
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\ApplicationWebListene
r.java:[14,1] cannot find symbol
[ERROR] symbol  : class DatabaseHelper
[ERROR] location: class com.epam.hhsystem.web.controllers.ApplicationWebListener
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[12,23] package org.apache.log4j does not exist
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[24,16] cannot find symbol
[ERROR] symbol  : class Logger
[ERROR] location: class com.epam.hhsystem.web.controllers.CustomAuthentificationProvider
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\AbstractController.ja
va:[49,20] cannot find symbol
[ERROR] symbol  : method getAllSkills()
[ERROR] location: class com.epam.hhsystem.services.UtilService
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[24,32] cannot find symbol
[ERROR] symbol  : variable Logger
[ERROR] location: class com.epam.hhsystem.web.controllers.CustomAuthentificationProvider
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[59,17] [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[63,17] [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[64,17] [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[65,17] [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\CustomAuthentificatio
nProvider.java:[66,17] [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
[ERROR] C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\src\main\java\com\epam\hhsystem\web\controllers\VacancyMenuController
.java:[79,20] cannot find symbol
[ERROR] symbol  : method getAllSkills()
[ERROR] location: class com.epam.hhsystem.services.UtilService
[ERROR] -> [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/MojoFailureException
C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI>
4

1 に答える 1

1

Maven のライフサイクルを理解する必要があります。maven test を実行すると、ビルド サイクル maven の検証、コンパイル、およびテスト フェーズが実行されます。

Maven 依存関係管理をチェックして、クラスjava.lang.NoClassDefFoundError: Lcom/epam/hhsystem/util/DatabaseHelper がテスト ケースを含むプロジェクトの Maven 管理依存関係にあることを確認できます。

ビルドサイクル

  1. 検証- プロジェクトが正しく、必要なすべての情報が利用可能であることを検証します
  2. compile - プロジェクトのソース コードをコンパイルします。
  3. test - 適切な単体テスト フレームワークを使用して、コンパイルされたソース コードをテストします。これらのテストでは、コードをパッケージ化またはデプロイする必要はありません
  4. package - コンパイルされたコードを取得し、JAR などの配布可能な形式でパッケージ化します。
  5. integration-test - 必要に応じてパッケージを処理し、統合テストを実行できる環境にデプロイします
  6. verify - チェックを実行して、パッケージが有効であり、品質基準を満たしていることを確認します
  7. install - 他のプロジェクトの依存関係としてローカルで使用するために、パッケージをローカル リポジトリにインストールします。
  8. デプロイ- 統合またはリリース環境で実行され、他の開発者やプロジェクトと共有するために最終パッケージをリモート リポジトリにコピーします。

Maven ライフサイクル: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

于 2013-10-23T14:20:35.447 に答える