I am part of a coding competition, the task is to create a RESTful online marketplace where users can post buy and sell requests via http.
I need to build a front end web service that accepts and stores these requests.
The tech requirements include both Spring boot and CXF. As far as I am aware, both CXF and Spring boot are capable of accepting http requests.
In spring boot, you use a controller like:
@Controller
@EnableAutoConfiguration
public class controller {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello, World!";
}
}
Whereas with CXF (using javax.ws.rs), the code might look like this:
@WebService(serviceName = "MarketService", targetNamespace = "http://localhost:9005")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public interface MarketService {
@GET
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({ MediaType.APPLICATION_JSON })
@Path("/sells/{id}")
public prod getProduct(@PathParam("id") int id);
Can someone help me understand the fundamental difference between these two approaches to handling http requests? Is there a way I can use both Spring Boot and CXF in the same application?