gpt4 book ai didi

jakarta-ee - JAX-RS Jersey : @XmlElementWrapper returns

转载 作者:行者123 更新时间:2023-12-01 14:46:19 32 4
gpt4 key购买 nike

我正在尝试根据 Jersey/Jaxb aliasing a List of beans 上接受的答案在 Artcile 的评论列表周围添加一个包装类

public class Article implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
...
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "ARTICLE_COMMENT",
joinColumns =
{
@JoinColumn(name = "ARTICLE_ID", referencedColumnName = "ID")
},
inverseJoinColumns =
{
@JoinColumn(name = "COMMENT_ID", referencedColumnName = "ID")
})
@XmlElementWrapper(name = "user_comments")
private List<Comment> comments;

public Article()
{
}
...
}

评论是

@XmlRootElement
@Entity
public class Comment implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;

/*
@ManyToMany(cascade={CascadeType.ALL},fetch=FetchType.EAGER)
private Collection<Article> articles;
*/
...
}

但是它返回这个错误

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Klasse enthält zwei Eigenschaften mit demselben Namen "comments"

将 Collection 更改为 List of comments 并没有太大变化。有人知道我能做什么吗?

最佳答案

只是一个大胆的猜测 - 尝试注释 getter 而不是属性。

关于jakarta-ee - JAX-RS Jersey : @XmlElementWrapper returns,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19359712/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com