Apache CXF + Spring Java config (no XML)

前端 未结 5 2174
孤城傲影
孤城傲影 2020-12-15 19:05

Trying to deploy a JAX-WS endpoint using Tomcat 7 Maven plugin and CXF 2.7.8. As a matter of preference, I don\'t want to have any XML config for Spring or CXF. I see severa

5条回答
  •  青春惊慌失措
    2020-12-15 19:44

    If you're using Spring Boot, you can use:

    
        org.apache.cxf
        cxf-spring-boot-starter-jaxws
        ${cxf.version} 
    
    

    To add an endpoint:

    import javax.xml.ws.Endpoint;
    import org.apache.cxf.Bus;
    import org.apache.cxf.jaxws.EndpointImpl;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    
    @Configuration
    public class WebServiceConfig {
    
        @Bean
        public Endpoint endpoint(Bus cxfBus) {
            EndpointImpl endpoint = new EndpointImpl(cxfBus, new Calculator());
            endpoint.publish("/CalculatorService");
            return endpoint;
        }
    }
    

    Official documentation of the CXF-Boot integration.

提交回复
热议问题