jaxb illegalannotationexceptions

kgqe7b3p  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(437)

我在这里读了几篇文章,但仍然不明白为什么会出现这个异常。一切都很好,我能够从spring的soapweb服务得到正确的响应。但后来我添加了springdatajpa和一些注解来将数据持久化到数据库中,异常开始出现在响应xml中。

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "number", propOrder = {
    "code",
    "fileNames",
    "error"
})
@Entity
public class Number {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @Column(name = "number")
    private int number;

    @XmlElement(required = true)
    @Column(name = "code")
    protected String code;

    @Column(name = "filenames")
    @Convert(converter = ListConverter.class)
    //@Transient
    protected List<String> fileNames;

    @XmlElement(required = true)
    @Column(name = "error")
    private String error;

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String value) {
        this.code = value;
    }

    public List<String> getFileNames() {
        if (fileNames == null) {
            fileNames = new ArrayList<String>();
        }
        return this.fileNames;
    }

    public String getError() {
        return error;
    }

    public void setError(String value) {
        this.error = value;
    }

}

下面是我得到的回应:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode>
<faultstring xml:lang="en">2 counts of IllegalAnnotationExceptions</faultstring>
</SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
v1l68za4

v1l68za41#

我为“id”和“number”字段添加了@xmltransite注解,现在一切正常。

相关问题