JAXB Exception: Class not known to this context

后端 未结 6 1034
-上瘾入骨i
-上瘾入骨i 2020-11-29 04:48

When I call a particular restful service method, which is built using CXF, I get the following error, anyone know why and how to resolve it?

6条回答
  •  無奈伤痛
    2020-11-29 05:28

    I had the same problem with spring boot. It resolved when i set package to marshaller.

    @Bean
    public Jaxb2Marshaller marshaller() throws Exception
    {
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
        marshaller.setPackagesToScan("com.octory.ws.dto");
        return marshaller;
    }
    
    @Bean
    public WebServiceTemplate webServiceTemplate(final Jaxb2Marshaller marshaller)   
    {
        WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
        webServiceTemplate.setMarshaller(marshaller);
        webServiceTemplate.setUnmarshaller(marshaller);
        return webServiceTemplate;
    }
    

提交回复
热议问题