小编use*_*512的帖子

杰克逊注释被忽略了

我正在尝试使用Jackson注释来重命名序列化期间生成的一些json标签.所有注释都编译良好,当我运行时,杰克逊序列化工作除了所有杰克逊注释完全被忽略.即使像@JsonIgnore或@JsonProperty这样的基本对json响应也没有影响.我在构建路径中拥有的库是:

jsr311-qpi-1.1.1.jar
jackson-[core|databind|annotations]-2.2.0.jar
Run Code Online (Sandbox Code Playgroud)

我正在Eclipse中运行jetty外部程序,外部程序设置如下:

Location: .../apache-maven-2.2.1/bin/mvnDebug.bat
working Directory: ${workspace_loc:/ohma-rest-svr}
Arguments: jetty:run
Run Code Online (Sandbox Code Playgroud)

将远程Java应用程序配置设置为:

Host: localhost
Port: 8000
Run Code Online (Sandbox Code Playgroud)

没有错误消息可以使用,我有点失去了尝试的东西.任何想法,将不胜感激.

这是我需要序列化的类的一些代码示例:

@XmlRootElement(name="ads-parameter")
public class DefineParameterResponse {

    private Date _createdAt = new Date();

    @JsonProperty("created-at")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd,HH:00", timezone="CET")
    @XmlElement
    public String getCreatedAt() {
        return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(_createdAt);
    }

    @JsonProperty("created-at")
    public void setCreatedAt(Date createdAt) {
        this._createdAt = createdAt;
    }


    private String _dataTitle1 = "Default Title1";
    @XmlElement
    @JsonProperty("data-title-1")
    public String getDataTitle1() {
        return _dataTitle1;
    }

    @JsonProperty("data-title-1")
    public void setDataTitle1(String dataTitle1) {
        this._dataTitle1 = dataTitle1;
    }


    @XmlElement
    @JsonProperty("data-title-2")
    public …
Run Code Online (Sandbox Code Playgroud)

java json annotations jetty jackson

5
推荐指数
1
解决办法
9223
查看次数

标签 统计

annotations ×1

jackson ×1

java ×1

jetty ×1

json ×1