Minimalizing SpringBoot+CXF to Implement WebService

1. There are many articles about how spring boot can access cxf. This article focuses on how spring boot 1.X and spirngboot 2.X can integrate cxf. Here is the code implementation.

maven dependence

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">






package com.mrb.minipj;

import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.jws.WebService;

 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.

 * @author MRB
public class Application {
    public static void main(String args[]){, args);

    public static  class CxfConfig {

        private Bus bus;

        public DemoService demoService;

        public Endpoint endpoint() {
            EndpointImpl endpoint = new EndpointImpl(bus, demoService);
            WebService serviceAnn = demoService.getClass().getDeclaredAnnotation(WebService.class);
            return endpoint;

    @WebService(serviceName = "demo",
            targetNamespace = ""

    public static class DemoService  {

        public String helloWorld(String param) {
            return "hello"+param;



2. Run Application.main, access: http://localhost:8700/services/centerwms?wsdl The results are as follows

3. Above, you can quickly start a Web Service demo, but this one was started by Springboot version 1.4.4, the following table is

cxf-spring-boot-starter-jaxws corresponds to spring boot version
cxf-spring-boot-starter-jaxws springboot
3.2.X 1.5.X
3.3.X 2.X

(1) Switch the version of cxf-spring-boot-starter-jaxws to 3.2.9:


The program can run normally.

(2) Switch the version of cxf-spring-boot-starter-jaxws to 3.3.0:

Errors not defined by the return class: Caused by: java.lang.NoClassDefFoundError: javax/validation/ClockProvider

The reason is that cxf-spring-boot-starter-jaxws defaults on java.validation:validation-api:1.1.0, which does not have this class defined.


Add < parent > dependencies directly and recompile them


You can see that this version has been switched:

Click Run to visit: http://localhost:8700/services/centerwms?wsdl The results are as follows

Tags: Spring Apache Maven Java

Posted on Tue, 08 Oct 2019 07:16:49 -0700 by dmayo2