2012-04-17 132 views
1

混淆後,我得到下面的異常:混淆JPA實體使用ProGuard

org.hibernate.AnnotationException: No identifier specified for entity: com.ad.ac.c.a 
    at org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:268) 
    at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:223) 
    at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686) 
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3977) 
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3931) 
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1368) 
    at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1345) 
    at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1477) 
    at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:193) 
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1096) 
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:278) 
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:362) 

我認爲這是做給Proguard的混淆getter和實體的制定者和改變的屬性名的事實。

回答

6

這裏需要我的ProGuard配置JPA正確

-keepattributes RuntimeVisibleAnnotations 
-keep @javax.persistence.* class * { 
    *; 
} 

工作,那會讓是非模糊的所有持久註解的類,並且不會刪除任何運行時的註釋。