JPA在Eclipse下使用JUnit进行测试时的NoSuchMethodError

基本框架:Struts2/Spring/JPA

症状描述:在使用WTP Server启动webapp时可以正常工作,但是采用Eclipse的Junit进行单元测试时抛出:

nested exception is java.lang.NoSuchMethodError: javax.persistence.PersistenceContext.properties()[Ljavax/persistence/PersistenceProperty;

解决方案:

1.在Run工具按钮中打开Run Configurations->Classpath

2.在其下的Bootstrap Entries中加入/WebContent/WEB-INF/lib/ejb3-persistence.jar

 

问题解决。

你可能感兴趣的:(eclipse,spring,jpa,单元测试,JUnit)