Younghae 2020-02-11 15:19 采纳率: 100%
浏览 786
已采纳

springboot maven项目使用代码混乱工具proguard的时候,发现类名称变成a\b\c了,但是局部变量名称还是原来的。

如题:springboot maven项目使用代码混乱工具proguard的时候,发现类名称变成a\b\c了,但是局部变量名称还是原来的。

我想保持类名是原来的,方法里面的局部变量改成a、b、c之类的应该要添加哪个配置呢?

# JDK目标版本1.8
-target 1.8
# 不做收缩(删除注释、未被引用代码)
-dontshrink
# 不做优化(变更代码实现逻辑)
-dontoptimize
-ignorewarnings
# 不路过非公用类文件及成员
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
<!--不用大小写混合类名机制
-dontusemixedcaseclassnames
# 优化时允许访问并修改有修饰符的类和类的成员
-allowaccessmodification
# 确定统一的混淆类的成员名称来增加混淆
-useuniqueclassmembernames
# 不混淆所有包名,本人测试混淆后WEB项目问题实在太多,毕竟Spring配置中有 大量固定写法的包名
-keeppackagenames
-adaptclassstrings
# -keepdirectories 
# 不混淆所有特殊的类
-keepattributes
    Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod
# This option will save all original methods parameters in files defined in -keep sections, otherwise all parameter names will be obfuscate.
-keepparameternames
-keep interface * extends * { *; }
-keepclassmembers class * {
    @org.springframework.beans.factory.annotation.Autowired *;
    @org.springframework.beans.factory.annotation.Value *;
    }

# 混淆这个包下的类
-keep class !com.example.** { *; }
# 不混淆main方法
-keep class com.example.Application { *; }

# 不混淆所有的set/get方法,毕竟项目中使用的部分第三方框架(例如Shiro)会用到大量的set/get映射 
-keepclassmembers public class * {void set*(***);*** get*();}

# 不对包类的类名进行混淆,但对类中的属性和方法混淆
-keep class com.example.controller.** 
-keep class com.example.service.** 
-keep class com.example.repository.** 

# 不混淆包下的所有类名,且类中的方法和属性也不混淆
-keep class com.example.redis.** { *; }
-keep class com.example.domain.** { *; }
-keep class com.example.dto.** { *; } 
-keep class com.example.config.**{ *; }
-keep class com.example.dao.** { *; }
  • 写回答

3条回答 默认 最新

  • dabocaiqq 2020-02-12 00:19
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题