精通hibernate(harness hibernate oreilly)中的一個」錯誤「

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.0:hbm
2ddl (generate-ddl) on project hib-dev-ch12: Could not get ConfigurationTask. ->

 [Help 1]

第十二章下載下來源代碼之後執行mvn test報以上錯誤。百思不得其解。導入eclipse,發現提示pom.xml錯所。




擦、、竟然生命週期綁定錯誤。根據對maven的理解,修改插件目標綁定的生命週期。

原來的插件配置:

<executions>
    <execution>
        <id>generate-ddl</id>
            <phase>process-classes</phase>//這個生命週期不對
        <goals>
            <goal>hbm2ddl</goal>
        </goals>
    </execution>
</executions>


修改爲:

<executions>
    <execution>
        <id>generate-ddl</id>
            <phase>post-clean</phase>//clean操作之後
        <goals>
            <goal>hbm2ddl</goal>
        </goals>
    </execution>
</executions>

修改保存後執行以下mvn clean 將target目標刪掉吧!!!

然後再次執行mvn test:

擦竟然是:

Results :


Tests in error:
  testSave(com.oreilly.hh.ArtistTest): Transaction failed


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


[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.881s
[INFO] Finished at: Mon Jan 14 14:25:28 CST 2013
[INFO] Final Memory: 9M/22M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
10:test (default-test) on project hib-dev-ch12: There are test failures.
[ERROR]

原來是ArtistTest.java類測試失敗。不管,刪掉這個類,執行mvn clean(同理:刪除target文件,不然mvn  test 還是要執行ArtistTest.java中的testSave方法)


然後執行那個mvn test :

[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ hib-dev-ch12 ---
[INFO] ----------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ----------------------------------------------------------------------
[INFO] Total time: 0.420s
[INFO] Finished at: Mon Jan 14 14:28:38 CST 2013
[INFO] Final Memory: 4M/15M

好了。這些終於success了。ArtistTest.java中的錯誤就不說了。

 





轉載於:https://my.oschina.net/zarger/blog/102040