-1
我正在Eclipse中運行Maven項目中的mvn測試。 JUnit測試通過,但是我得到一個堆棧跟蹤錯誤,下面是錯誤。這與我認爲的javax.peristence.Persistence類有關。我做了一些研究,我想我需要將javax庫添加到類路徑中(獲取一些關於如何做到這一點的建議會很好,我已經把這個依賴關係放在了pom.xml中,但仍然出現錯誤。我想在pom.xml明確列出能解決我的問題。Maven測試,構建失敗,java.lang.NoClassDefFoundError
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>ejb3-persistence</artifactId>
<version>1.0.2.GA</version>
<type>pom</type>
</dependency>
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.399 sec <<< FAILURE! -
in tableTests.TestBaseDataConfig
testCreateDeleteRow(tableTests.TestBaseDataConfig) Time elapsed: 0.087 sec <<< ERROR!
java.lang.NoClassDefFoundError: javax/persistence/Persistence
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at persistence.PersistenceUtil.<clinit>(PersistenceUtil.java:12)
at config.AbstractTableConfig.createRow(AbstractTableConfig.java:11)
at tableTests.TestBaseDataConfig.testCreateDeleteRow(TestBaseDataConfig.java:51)