Spring Rooを使用してWebプロジェクトを構築する際にMojoFailureExceptionを修正する方法

最近私はウェブプロジェクトを構築するために、ローン1.2.0.M1でspring STSを使用します。私はjpaをセットアップし、いくつかのフィールドを持つエンティティを作成し、エンティティ用のリポジトリとサービスレイヤを作成し、テストを実行すると次のエラーが表示されます。

roo> perform tests 
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building WebApplication 0.1.0.BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- aspectj-maven-plugin:1.2:compile (default) @ WebApplication ---
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ WebApplication ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ WebApplication ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- aspectj-maven-plugin:1.2:test-compile (default) @ WebApplication ---
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ WebApplication ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ WebApplication ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.8:test (default-test) @ WebApplication ---
[INFO] Surefire report directory: /Users/charlesli/Documents/workspace-spring/WebApplication/target/surefire-reports
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.936s
[INFO] Finished at: Fri Oct 28 20:59:59 EST 2011
[INFO] Final Memory: 6M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.8:test (default-test) on project WebApplication: There are test failures.
[ERROR] 
[ERROR] Please refer to /Users/charlesli/Documents/workspace-spring/WebApplication/target/surefire-reports for the individual test results.
[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

ターミナルでmvnテストを実行すると、次のエラーが表示されます。

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.614s
[INFO] Finished at: Fri Oct 28 21:06:50 EST 2011
[INFO] Final Memory: 6M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.8:test (default-test) on project WebApplication: There are test failures.
[ERROR] 
[ERROR] Please refer to /Users/charlesli/Documents/workspace-spring/WebApplication/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.8:test (default-test) on project WebApplication: There are test failures.

Please refer to /Users/charlesli/Documents/workspace-spring/WebApplication/target/surefire-reports for the individual test results.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    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)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

Please refer to /Users/charlesli/Documents/workspace-spring/WebApplication/target/surefire-reports for the individual test results.
    at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:74)
    at org.apache.maven.plugin.surefire.SurefirePlugin.writeSummary(SurefirePlugin.java:644)
    at org.apache.maven.plugin.surefire.SurefirePlugin.executeAfterPreconditionsChecked(SurefirePlugin.java:640)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:103)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
[ERROR] 
[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

私は次のコマンドを使ってプロジェクトをビルドします:

jpa setup --database MYSQL --provider HIBERNATE --databaseName App --hostName localhost --password root --persistenceUnit app --transactionManager appTransactionManager --userName root
entity --class ~.app.domain.DomainObjBaseModel --mappedSuperclass --persistenceUnit app --transactionManager appTransactionManager

// After running the above command, I manually add the following stuff in DomainObjBaseModel, because I don't know how to customise the roo auto generate stuff
    @Id @GeneratedValue(generator="system-uuid")
    @GenericGenerator(name="system-uuid", strategy = "uuid")
    @Column(unique = true, name = "id", nullable = false, length=32)
    private String id;
// After this action, I continue run the following commands.

entity --class ~.app.domain.Application --extends com.crazysoft.web.app.domain.DomainObjBaseModel --persistenceUnit app --transactionManager appTransactionManager --serializable --testAutomatically
repository jpa --interface ~.app.repository.ApplicationRepository --entity ~.app.domain.Application
service --interface ~.app.service.ApplicationService --entity ~.app.domain.Application

これは、Mavenプラグインの設定です:


            org.apache.maven.plugins
            maven-compiler-plugin
            2.3.2
            
                1.6
                1.6
                UTF-8
            
        

上記の作業を完了し、STSのrooシェルを通して perform tests を実行すると、上記のエラーが発生します。

誰でもこの例外が発生する理由を知っていますか?私は何か間違っているのですか?それを修正する方法は?

私を助けてください!

前もって感謝します!

4

3 答え

1つまたは複数のテストが機能していません。

/Users/charlesli/Documents/workspace-spring/WebApplication/target/surefire-reports にあるファイルを見てください(通常、大きなファイルには問題があります)

そこにテスト結果があり、テストハットが壊れています。このファイルに2つのStacktraceが含まれていれば、この問題を解決できます。

(BTW:JUnitプラグイン(パッケージエクスプローラ、右クリック、JUnitとして実行)経由でeclipseでテストを実行することもできます。IDEでスタックトレースを行い、ファイルを検索する必要はありません。)


私は、DB接続が正しくないと思います。しかし、これは単なる推測です。

7
追加された

Right click on Project-> Properties--> select project facets--> choose Java correct version which is installed on your system. Then it will works fine.

3
追加された
あなたは私の一日を救った! <3
追加された 著者 Arsal Imam,

コンパイラが使用できないことがわかっている場合は、次のように環境をjreからjdkに置き換えることができます。

  • project_name > Build Path > Configure Build Path > Libraries > (double-click) JRE System Libraries > Alternate Jre : jdk 1.8 >ok
  • Then from Installed JRES option in Libraries select jdk 1.8
  • Project > Clean
  • Maven > Update
0
追加された