当我通过 http://www.jsonschema2pojo.org/ 生成 POJO 时我得到这样的东西:
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
@Generated("org.jsonschema2pojo")
public class Name {
//...
}
但 Android Studio 无法识别 javax.annotation.Generated
,我必须删除两行代码
import javax.annotation.Generated;
和
@Generated("org.jsonschema2pojo")
形成每个 POJO,这很痛苦。有没有办法抑制http://www.jsonschema2pojo.org/从添加注释?
最佳答案
如果您使用的是 Gradle,请转到“app/”文件夹中的 build.gradle 文件,并在 dependencies {...} 中添加:
compile 'org.glassfish:javax.annotation:10.0-b28'
然后重建项目。这应该可以解决问题。
关于android - jsonschema2pojo 生成的 POJO 具有 Android Studio 无法理解的注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37046649/