0
저지와 MOXy를 사용하여 웹 서비스를 구현 중입니다. webservice는 JSON 결과로 데이터를 반환합니다. 다음 래퍼 클래스를 사용하여 일부 컬렉션을 래핑하려고합니다.JAXB 일반 목록이있는 마샬 래퍼 객체
public class PaginationWrapper<T>
{
private List<T> data;
//other fields
private...
public List<T> getData()
{
return data;
}
public void setData(List<T> data)
{
this.data = data;
}
//other getter and setter
}
제네릭을 사용하면 결과가 반환되지 않습니다. 가 제기 예외입니다 :
javax.xml.bind.MarshalException
- with linked exception:
[Exception [EclipseLink-25003] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred marshalling the object
Internal Exception: Exception [EclipseLink-25007] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor for class packagereplaced.PaginationWrapper was not found in the project. For JAXB, if the JAXBContext was bootstrapped using TypeMappingInfo[] you must call a marshal method that accepts TypeMappingInfo as an input parameter.]
그 오류를 수정합니다 제네릭 타입을 교체하지만 나는 내가 가지고있는 각 데이터 객체에 대한 랩퍼를 작성 싶지 않다. 왜냐하면 저스틴과 moxy가있는 웹 서비스를 구현하고 있기 때문에 마샬링 자체에 액세스 할 필요가 없습니다. 주석 기반 솔루션이나 저지에서 작동하는 다른 것이 필요합니다.)