/** *

This will be picked up in a Servlet 3 environment like Apache Tomcat 7. * *

This replaces web.xml. * */ public class MvcRestApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class [] getRootConfigClasses() { return new Class[]{}; } @Override protected Class[] getServletConfigClasses() { return new Class[]{ RestConfiguration.class }; } @Override protected String[] getServletMappings(){ return new String[]{"/"}; } } /** * Installs Spring MVC and all the required support for JSON assuming * Jackson's on the CLASSPATH */ @EnableWebMvc @ComponentScan @Configuration class RestConfiguration { // that's all! } /** * A simple Spring MVC REST controller. The returned value (Customer) will * be converted into JSON if the client signals that it can read JSON (using the * ACCEPT header.) */ @Controller class StatusController { @RequestMapping(value= "/customers/{customerId}", method= RequestMethod.GET) public @ResponseBody Customer loadCustomer(@PathVariable long customerId ) { // return a POJO Customer somehow (perhaps look it up in a database?) return someCustomer ; } }