title: Spring Boot API with Multiple Controllers?
body: <p>I am starting to learn Spring Boot. I am struggling to find an example with multiple RestControllers, which indicates to me that I may be doing something wrong. I am trying a very simple example: The goal is to make calls like the following:</p>
  
  <pre><code>localhost:8080/
  localhost:8080/employees/bob
  localhost:8080/departments
  </code></pre>
  
  <p>I can only get localhost:8080/ to display. The other calls return response: This application has no explicit mapping for /error, so you are seeing this as a fallback. </p>
  
  <pre><code>com.demo.departments
  Department.java
  DepartmentController.java
  
  com.demo.employees
  Employee.java
  EmployeeController.java
  
  com.demo
  BootDemoApplication.java
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>package com.demo.departments
  @RestController
  @RequestMapping("/departments")
  public class DepartmentController {
  
  
  @RequestMapping("")
  public String get(){
      return "test..";
  
  }
  
  @RequestMapping("/list")
  public List&lt;Department&gt; getDepartments(){
      return null;
  
  }
  
  }
  --------------------------------------------------------------------
  package com.demo.employees
  @RestController
  @RequestMapping("/employees")
  public class EmployeeController {
  
  Employee e =new Employee();
  
  @RequestMapping(value = "/{name}", method = RequestMethod.GET, produces = "application/json")
  public Employee getEmployeeInJSON(@PathVariable String name) {
  
   e.setName(name);
   e.setEmail("employee1@genuitec.com");
  
   return e;
  
  }
  }
  -----------------------------------------------------------------------
  
  package com.demo
  @RestController
  @SpringBootApplication
  
  public class BootDemoApplication {
  
  public static void main(String[] args) {
      SpringApplication.run(BootDemoApplication.class, args);
  }
  
  @RequestMapping("/")
  String home(){
      return "&lt;html&gt; This is the home page for Boot Demo.&lt;/html&gt;";
  }
  </code></pre>