Spring Boot vs. Apache CXF for RESTful Web Services? Spring Boot vs. Apache CXF for RESTful Web Services? spring spring

Spring Boot vs. Apache CXF for RESTful Web Services?


Spring MVC and Apache CXF are 2 separate frameworks to handle HTTP requests and that can be used to build REST web services.

  • Spring MVC is a project under the Spring "umbrella" (and therefore strongly tied to the Spring framework on top of which it's built),
  • Apache CXF is a open-source implementation of JAX-RS (REST) and JAX-WS (SOAP). Apache CXF can be run standalone or be included in a Spring application.

If you are looking to build a REST web service, they are pretty much mutually exclusive (you have to pick one). If all you're going to do is build REST web services, then they're pretty much equivalent. If you also need to have an MVC framework to serve HTML pages, then Spring MVC has that capability (CXF does not).

Personal opinion: Spring MVC is easier to get started with (thanks to Spring Boot which handles most of the configuration for you) than CXF (which requires more XML configuration).

PS: in your CXF example, you have a @WebService annotation. This annotation is part of JAX-WS (SOAP), not JAX-RS (REST). You probably don't need it.


Check this project out for nice starter for JAX-RS (REST) that leverages CXF on Tomcat via TomEE.

Everything is all setup and ready to go.

Long description here:

Note, running CXF "Standalone" still requires a Servlet container (Tomcat or Jetty), so the above is several steps completed, simplified and finished in a small starter project. Designed for impatient people (like myself) that don't like to read directions and just like to start hacking. Always easier for me to start with something that works and then tweak it.


Use the Spring Boot CXF JAX-RS starter by adding:

<dependency>  <groupId>org.apache.cxf</groupId>  <artifactId>cxf-spring-boot-starter-jaxrs</artifactId>  <version>3.1.7</version></dependency>

See also: http://cxf.apache.org/docs/springboot.html