Apache camel 未找到org.apache.cxf.message.MessageContentsList类的消息正文编写器,ContentType:application/xml
当我尝试使用@product(APPLICATION_JSON)进行测试时,我得到了一个成功的响应。Apache camel 未找到org.apache.cxf.message.MessageContentsList类的消息正文编写器,ContentType:application/xml,apache-camel,cxf,activemq,Apache Camel,Cxf,Activemq,当我尝试使用@product(APPLICATION_JSON)进行测试时,我得到了一个成功的响应。 不确定这是camel cxf的问题还是我的应用程序中的问题?看起来像是JAXB配置问题。您是否已将其配置为JSON支持? 配置示例: Below is my RestResource class. import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.
不确定这是camel cxf的问题还是我的应用程序中的问题?看起来像是JAXB配置问题。您是否已将其配置为JSON支持? 配置示例:
Below is my RestResource class.
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import com.mayank.restservice.model.ChequeDetails;
import com.mayank.restservice.service.RestfulService;
public class RestfulResource {
private RestfulService restfulservice;
public void setRestfulservice(RestfulService restfulservice) {
this.restfulservice = restfulservice;
}
@Path("post")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_XML)
public ChequeDetails persistDB(ChequeDetails chequedetails){
return restfulservice.persistDB(chequedetails);
}
}
/
看起来像是JAXB配置问题。您是否已将其配置为JSON支持?
配置示例:
Below is my RestResource class.
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import com.mayank.restservice.model.ChequeDetails;
import com.mayank.restservice.service.RestfulService;
public class RestfulResource {
private RestfulService restfulservice;
public void setRestfulservice(RestfulService restfulservice) {
this.restfulservice = restfulservice;
}
@Path("post")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_XML)
public ChequeDetails persistDB(ChequeDetails chequedetails){
return restfulservice.persistDB(chequedetails);
}
}
/
您找到解决方案了吗?您找到解决方案了吗?
<beans xmlns:util="http://www.springframework.org/schema/util">
<bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
<property name="namespaceMap" ref="jsonNamespaceMap"/>
</bean>
<util:map id="jsonNamespaceMap" map-class="java.util.Hashtable">
<entry key="http://www.example.org/books" value="b"/>
</util:map>
/<beans>