如何在Proguard混淆后保留@PathVariable参数名称

时间:2017-09-07 18:39:38

标签: java spring proguard obfuscation

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

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

1 个答案:

答案 0 :(得分:0)

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

这是我的proguard配置:

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