0

I am trying to obfuscate a Spring Boot application using Proguard. Proguard rename the packages and classes alphabetically, so I'll be having classes like a.a, a.b, a.c, b.a and b.b...

My problem is that @RestController, @Configuration, @Service annotated classes with the same name (even though in different packages) generate the following exception

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.test.sirh.CoreApp]; nested exception is

org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'c' for bean class [com.test.sirh.g.a.c] conflicts with existing, non-compatible bean definition of same name and class [com.test.sirh.b.c]

Keeping the classes with those annotations would solve the problem, but I'll end up with almost half the classes not obfuscated. Is there anyway so Proguard generates the classes alphabetically (that doesn't change) but without returning from "a" in each package? In way that I end up with a.a, a.b, a.c and b.d (instead of b.a).

And yes I am keeping the annotations. Just obfuscating the name of classes/classmembers.

My options :

<options>
    <option>-injar ${project.build.directory}/classes</option>
    <option>-outjar ${project.build.directory}/proguard-obf-classes </option>
    <option>-target 1.8</option>    
    <option>-dontshrink</option>
    <option>-dontoptimize</option>
    <option>-dontusemixedcaseclassnames</option>
    <option>-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod</option> 
    <option>-keepparameternames</option>    
    <option>-keepclasseswithmembers public class * {public static void main(java.lang.String[]);}</option>
    <option>-keep @org.springframework.context.annotation.Configuration public class *</option>
    <option>-keepclassmembers enum * { *; } </option>
</options>

Thank you.

  • Possible duplicate of [Proguard vs Annotations](https://stackoverflow.com/questions/7378693/proguard-vs-annotations) – UserF40 Aug 01 '17 at 18:39
  • @UserF40, I am already keeping the annotations. And that is the main reason of the conflict. The main difference is in that link, the annotations have attributes **@Table(name="test")** and I don't. – hamzagiveshugs Aug 02 '17 at 08:28
  • Turned out to be, indeed, duplicate of https://stackoverflow.com/questions/10299895/conflicts-with-existing-non-compatible-bean-definition-of-same-name-and-class-a – hamzagiveshugs Aug 02 '17 at 08:59

0 Answers0