如何配置ProGuard的尊重杰克逊模式? [英] How to configure ProGuard to respect Jackson model?
问题描述
下面的类描述了一个模式,我使用杰克逊2.2 一个以.json文件中读取。
The following class describes a model I read from a .json file using Jackson 2.2.
public class Product {
public String name;
public int width;
}
借助摇篮的构建过程调用的 ProGuard的萎缩,混淆发布版本。
当我启动应用程序时出现以下错误信息:
The Gradle build process invokes ProGuard to shrink and obfuscate the release build. When I start the application the following error message occurs:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
Unrecognized field "name" (class com.example.b.c),
not marked as ignorable (0 known properties: ])
如何配置ProGuard的或批注产品
类,以便杰克逊仍然有效?
How can I configure ProGuard or annotate the Product
class so that Jackson still works?
推荐答案
我要管理,我在我的问题简化的例子。这个问题的解决方案是让干将和制定者中的ProGuard我不得不额外定义的模型类,使杰克逊的工作。
I have to admin that I simplified the example in my question. The solution to the problem was to keep getters and setters in ProGuard which I had to additionally define in model classes to make Jackson work.
-keep public class com.example.models.Product {
public *** get*();
public void set*(***);
}
这篇关于如何配置ProGuard的尊重杰克逊模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!