【问题标题】:Unable to configure EntityManagerFactory - Hibernate Mockito无法配置 EntityManagerFactory - Hibernate Mockito
【发布时间】:2015-10-04 12:59:36
【问题描述】:

当我在 mockito 测试中运行我的代码时,我得到了这个错误 我的权力模拟忽略是:

    @PowerMockIgnore({"javax.management.*", "ch.qos.logback.*", "org.slf4j.*", "javax.persistence.*", "org.w3c.*", "javax.net.ssl.*","javax.xml.parsers.*", "com.sun.org.apache.xerces.internal.*.*"})

Caused by: javax.persistence.PersistenceException: javax.persistence.PersistenceException: Unable to configure EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:385)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at com.hasintech.authorizerportal.database.DbHelper.initFactory(DbHelper.java:63)
at com.hasintech.authorizerportal.database.DbHelper.<clinit>(DbHelper.java:27)
... 34 more
Caused by: java.lang.IllegalArgumentException: No SchemaFactory that implements the schema language specified by: http://www.w3.org/2001/XMLSchema could be loaded
at javax.xml.validation.SchemaFactory.newInstance(SchemaFactory.java:204)
at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:91)
at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:171)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:324)
... 38 more

【问题讨论】:

    标签: hibernate jpa mockito


    【解决方案1】:

    将“org.hibernate.*”添加到电源模拟忽略:

    @PowerMockIgnore({"javax.management.*", "ch.qos.logback.*", "org.slf4j.*", "javax.persistence.*", "org.w3c.*", "javax.net.ssl.*", "javax.xml.parsers.*", "com.sun.org.apache.xerces.internal.*.*", "org.hibernate.*"}) 
    

    【讨论】:

      猜你喜欢
      • 2011-04-14
      • 1970-01-01
      • 2013-07-28
      • 2012-05-15
      • 2017-03-05
      • 2013-09-05
      • 2011-07-05
      • 2012-09-01
      • 2012-11-20
      相关资源
      最近更新 更多