【问题标题】:How to keep @PathVariable parameter name after obfuscation by ProguardProguard混淆后如何保留@PathVariable参数名称
【发布时间】:2018-02-16 14:08:36
【问题描述】:

我正在为 Rest Service 使用 Spring 框架。我有一个下面有 @PathVariable id 的 Rest API。但是在 Proguard 混淆之后,参数 'id' 更改为类似于 'parama' 的东西,这会导致 REST 无法工作,因为它与 @RequestMapping 中的定义不匹配。如何解决它以保留参数名称?

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public void getAccount(@PathVariable int id) {
        ...
}

【问题讨论】:

    标签: java spring proguard obfuscation


    【解决方案1】:

    -keepparameternames 将参数名称保存在公共库方法的“LocalVariableTable”和“LocalVariableTypeTable”属性中。

    这是我的 proguard 配置:

    -keepparameternames
    -keepattributes SourceFile,LineNumberTable,*Annotation*
    -keepclasseswithmembers class test.rest.controller.* {
        public <methods>;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多