title: mongoTemplate bean could not be found
body: <p>I am building a very simple Spring boot app with mvc + mongodb. I used Spring initializer to create the proj with web, thymeleaf and mongo dependencies. I have one controller, one model and a view but I keep on getting an error when trying to execute the app:</p>
  
  <pre><code>Description:
  
  Field repo in com.example.CustomerController required a bean named 'mongoTemplate' that could not be found.
  
  
  Action:
  
  Consider defining a bean named 'mongoTemplate' in your configuration.
  </code></pre>
  
  <p>CustomerController:</p>
  
  <pre><code>import model.Customer;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  /**
   * Created by Hello on 25/04/2017.
   */
  
  @Controller
  @RequestMapping("/home")
  public class CustomerController {
  
      @Autowired
      CustomerMongoRepo repo;
  
  
      @RequestMapping(value = "/home", method= RequestMethod.GET)
      public String viewingHome(Model model){
          //initDB();
          model.addAttribute("key", "THIS IS FROM THE MODEL");
  
          return "homepage";
      }
  
  }
  </code></pre>
  
  <p>CustomerMongoRepo:</p>
  
  <pre><code>    import org.springframework.data.repository.CrudRepository;
  
          import model.Customer;
  
  public interface CustomerMongoRepo extends CrudRepository {}
  </code></pre>
  
  <p>MainApp:</p>
  
  <pre><code>import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
  import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
  import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
  
  @SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
  public class DemoApplication extends WebMvcAutoConfiguration {
  
  
      public static void main(String[] args) {
          SpringApplication.run(DemoApplication.class, args);
      }
  }
  </code></pre>
  
  <p>Customer Model:</p>
  
  <pre><code>import org.springframework.data.annotation.Id;
  import org.springframework.data.mongodb.core.mapping.Document;
  
  /**
   * Created by Hello on 25/04/2017.
   */
  
  @Document(collection = "customerCollection")
  public class Customer {
      @Id
      private int id;
      private String fName;
      private String sName;
  
      public Customer(){}
  
      public Customer(int id, String fName, String sName){
          setfName(fName);
          setsName(sName);
          setId(id);
      }
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getfName() {
          return fName;
      }
  
      public void setfName(String fName) {
          this.fName = fName;
      }
  
      public String getsName() {
          return sName;
      }
  
      public void setsName(String sName) {
          this.sName = sName;
      }
  
  
  }
  </code></pre>
  
  <p>My Application Properties:</p>
  
  <pre><code>spring.data.mongodb.database=customer
  spring.data.mongodb.host=localhost
  spring.data.mongodb.port=27017
  spring.data.mongodb.uri=mongodb://localhost:27018/mydb
  spring.data.mongo.repositories.enabled=true
  </code></pre>