title: When I want to run my j2ee+maven+spring-boot+mysql project on idea, there comes an error
body: <pre><code>Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
  2020-06-23 22:33:08.783 ERROR 14944 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
  
  ***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  Field recordRepository in com.myspring.demo.controller.MyController required a bean of type 'com.myspring.demo.Dao.RecordRepository' that could not be found.
  
  The injection point has the following annotations:
      - @org.springframework.beans.factory.annotation.Autowired(required=true)
  
  
  Action:
  
  Consider defining a bean of type 'com.myspring.demo.Dao.RecordRepository' in your configuration.
  </code></pre>
  <p>I have noticed that <code>com.myspring.demo.Dao.RecordRepository</code>,so I look for the code,and here is the code of Mycontroller.java</p>
  <pre><code>package com.myspring.demo.controller;
  
  import com.myspring.demo.Dao.AppRepository;
  import com.myspring.demo.Dao.RecordRepository;
  import com.myspring.demo.Dao.StaffRepository;
  import com.myspring.demo.entity.App;
  import com.myspring.demo.entity.Record;
  import com.myspring.demo.entity.Staff;
  import com.myspring.demo.model.UsrSession;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.servlet.ModelAndView;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.List;
  
  @Controller
  @RequestMapping(&quot;/me&quot;)
  public class MyController {
      @RequestMapping(&quot;my&quot;)
      public String my(){
          return &quot;my&quot;;
          }
      @RequestMapping(&quot;punch&quot;)
      public String punch(){
          return &quot;punch&quot;;
      }
      @RequestMapping(&quot;check&quot;)
      public ModelAndView check(HttpSession httpSession){
          UsrSession usrSession= (UsrSession) httpSession.getAttribute(&quot;usr&quot;);
          int id=usrSession.getId();
          String currentMonth = new SimpleDateFormat(&quot;yyyy-MM&quot;).format(new Date(System.currentTimeMillis()));
          List&lt;Record&gt;records=recordRepository.findAllByStaffId(id);
          List&lt;Record&gt;recordList=new ArrayList&lt;&gt;();
          if(!records.isEmpty()){
               for(Record r : records){
                  String date=r.getDate();
                  if(date.startsWith(currentMonth)){
                      recordList.add(r);
                  }
              } 
          }
          ModelAndView modelAndView=new ModelAndView();
          modelAndView.setViewName(&quot;/check&quot;);
          modelAndView.addObject(&quot;records&quot;,recordList);
          return modelAndView;
      }
      @RequestMapping(&quot;/app&quot;)
      public String application(HttpServletRequest request,HttpSession httpSession){
          String recordid=request.getParameter(&quot;recordId&quot;);
          String reason=request.getParameter(&quot;reason&quot;);
          int id=Integer.parseInt(recordid);
  
          App app =new App();
          app.setExcuse(reason);
          app.setRecordId(id);
          UsrSession usrSession= (UsrSession) httpSession.getAttribute(&quot;usr&quot;);
          int staffid=usrSession.getId();
          int departid=staffRepository.findAllByStaffId(staffid).getDepartmentId();
          app.setStaffId(staffid);
          String currentDate = new SimpleDateFormat(&quot;yyyy-MM-dd&quot;).format(new 
  Date(System.currentTimeMillis()));
          app.setAppDay(currentDate);
          app.setState(0);
          app.setDepartmentId(departid);
  
          appRepository.save(app);
              return &quot;my&quot;;
      }
      @RequestMapping(&quot;/confirm&quot;)
      public ModelAndView confirm(HttpServletRequest request,HttpSession httpSession){
          UsrSession usrSession= (UsrSession) httpSession.getAttribute(&quot;usr&quot;);
          if(usrSession.getType()==0) //员工
          {
              int id=usrSession.getId();
              List&lt;App&gt;apps=appRepository.findAllByStaffId(id);
              ModelAndView modelAndView=new ModelAndView();
              modelAndView.setViewName(&quot;/checkApp&quot;);
              modelAndView.addObject(&quot;apps&quot;,apps);
               return modelAndView;
  
          }
          else
          {
               int id=usrSession.getId();
              Staff s=staffRepository.findAllByStaffId(id);
              List&lt;App&gt;apps=appRepository.findAllByDepartmentId(s.getDepartmentId());
              ModelAndView modelAndView=new ModelAndView();
              modelAndView.setViewName(&quot;/confirmApp&quot;);
              modelAndView.addObject(&quot;apps&quot;,apps);
              return modelAndView;
          }
      }
      @RequestMapping(&quot;/modify&quot;)
      public String modify(HttpSession session, HttpServletRequest request){
          String appId=request.getParameter(&quot;recordId&quot;);
          int aId=Integer.parseInt(appId);
          List&lt;App&gt;apps=appRepository.findAllByAppId(aId);
          if(!apps.isEmpty())
          {
              App app=apps.get(0);
              int rid=app.getRecordId()+1;
              List&lt;Record&gt;records=recordRepository.findAllByRecordId(rid);
             if(!records.isEmpty())
          {
              Record r= records.get(0);
              r.setState(&quot;ok&quot;);
              recordRepository.save(r);
          }
              apps.get(0).setState(1);
              appRepository.save(app);
          }
          return&quot;my&quot;;
      }
      }
      @Autowired
      RecordRepository recordRepository;
      @Autowired
      AppRepository appRepository;
      @Autowired
      StaffRepository staffRepository;
  
  }
  </code></pre>
  <p>it seems that the problem is coming at the last 6 lines.
  and here is the RecordRepository.java</p>
  <pre><code>package com.myspring.demo.Dao;
  
  import com.myspring.demo.entity.Record;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Component;
  import org.springframework.stereotype.Repository;
  import org.springframework.stereotype.Service;
  
  import java.util.List;
  
  public interface RecordRepository extends JpaRepository&lt;Record,Integer&gt; {
      public List&lt;Record&gt; findAllByStaffIdAndAndDate(Integer id,String date);
      public List&lt;Record&gt; findAllByStaffId(Integer id);
      public List&lt;Record&gt; findAllByRecordId(Integer id);
  }
  </code></pre>
  <p>And this is the application.properties</p>
  <pre><code>server.port=8080
  spring.datasource.jdbc-url=jdbc:mysql://127.0.0.1:3306/?useUnicode=true&amp;characterEncoding=UTF-8&amp;useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC
  spring.datasource.username=root
  spring.datasource.password=root
  spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  spring.jpa.database=MYSQL
  spring.jpa.show-sql=true
  
  spring.jpa.hibernate.ddl-auto=update
  
  spring.http.encoding.force=true
  spring.http.encoding.charset=UTF-8
  spring.http.encoding.enabled=true
  server.tomcat.uri-encoding=UTF-8
  </code></pre>
  <p>And this is the pom.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
       xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.1.5.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  &lt;groupId&gt;com.myspring&lt;/groupId&gt;
  &lt;artifactId&gt;demo&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;demo&lt;/name&gt;
  &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
  &lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;8.0.16&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- spring-boot-configuration-processor --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-configuration-processor&lt;/artifactId&gt; &lt;optional&gt;true&lt;/optional&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.quartz-scheduler&lt;/groupId&gt;
          &lt;artifactId&gt;quartz&lt;/artifactId&gt;
          &lt;version&gt;2.2.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;commons-lang&lt;/groupId&gt;
          &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
          &lt;version&gt;2.6&lt;/version&gt;
      &lt;/dependency&gt;
  
  
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.2.7.RELEASE&lt;/version&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  
      &lt;resources&gt;
          &lt;resource&gt;
              &lt;directory&gt;src/main/resources&lt;/directory&gt;
              &lt;includes&gt;
                  &lt;include&gt;application.properties&lt;/include&gt;
              &lt;/includes&gt;
              &lt;filtering&gt;false&lt;/filtering&gt;
          &lt;/resource&gt;
      &lt;/resources&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>the img of project's struct<a href="https://i.stack.imgur.com/R17UL.png" rel="nofollow noreferrer">enter image description here</a></p>