title: Field _________ in required a bean of type _________ that could not be found
body: <p>Working in intellij community edition.
  How can i resolve this error. I have tried everything i could find on stackoverflow</p>
  <p><strong>Console</strong></p>
  <pre><code>C:\Users\dell\.jdks\openjdk-17.0.2\bin\java.exe &quot;-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.1\lib\idea_rt.jar=60395:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.1\bin&quot; -Dfile.encoding=UTF-8 -classpath C:\Users\dell\OneDrive\Desktop\dailyWagers\target\classes;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa\2.6.3\spring-boot-starter-data-jpa-2.6.3.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-aop\2.6.3\spring-boot-starter-aop-2.6.3.jar;C:\Users\dell\.m2\repository\org\aspectj\aspectjweaver\1.9.7\aspectjweaver-1.9.7.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.6.3\spring-boot-starter-jdbc-2.6.3.jar;C:\Users\dell\.m2\repository\com\zaxxer\HikariCP\4.0.3\HikariCP-4.0.3.jar;C:\Users\dell\.m2\repository\org\springframework\spring-jdbc\5.3.15\spring-jdbc-5.3.15.jar;C:\Users\dell\.m2\repository\jakarta\transaction\jakarta.transaction-api\1.3.3\jakarta.transaction-api-1.3.3.jar;C:\Users\dell\.m2\repository\jakarta\persistence\jakarta.persistence-api\2.2.3\jakarta.persistence-api-2.2.3.jar;C:\Users\dell\.m2\repository\org\hibernate\validator\hibernate-validator\6.2.0.Final\hibernate-validator-6.2.0.Final.jar;C:\Users\dell\.m2\repository\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;C:\Users\dell\.m2\repository\org\jboss\logging\jboss-logging\3.4.3.Final\jboss-logging-3.4.3.Final.jar;C:\Users\dell\.m2\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;C:\Users\dell\.m2\repository\org\springframework\data\spring-data-jpa\2.6.1\spring-data-jpa-2.6.1.jar;C:\Users\dell\.m2\repository\org\springframework\data\spring-data-commons\2.6.1\spring-data-commons-2.6.1.jar;C:\Users\dell\.m2\repository\org\springframework\spring-orm\5.3.15\spring-orm-5.3.15.jar;C:\Users\dell\.m2\repository\org\springframework\spring-context\5.3.15\spring-context-5.3.15.jar;C:\Users\dell\.m2\repository\org\springframework\spring-tx\5.3.15\spring-tx-5.3.15.jar;C:\Users\dell\.m2\repository\org\springframework\spring-beans\5.3.15\spring-beans-5.3.15.jar;C:\Users\dell\.m2\repository\org\slf4j\slf4j-api\1.7.33\slf4j-api-1.7.33.jar;C:\Users\dell\.m2\repository\org\springframework\spring-aspects\5.3.15\spring-aspects-5.3.15.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-security\2.6.3\spring-boot-starter-security-2.6.3.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter\2.6.3\spring-boot-starter-2.6.3.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot\2.6.3\spring-boot-2.6.3.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.6.3\spring-boot-autoconfigure-2.6.3.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.6.3\spring-boot-starter-logging-2.6.3.jar;C:\Users\dell\.m2\repository\ch\qos\logback\logback-classic\1.2.10\logback-classic-1.2.10.jar;C:\Users\dell\.m2\repository\ch\qos\logback\logback-core\1.2.10\logback-core-1.2.10.jar;C:\Users\dell\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.17.1\log4j-to-slf4j-2.17.1.jar;C:\Users\dell\.m2\repository\org\apache\logging\log4j\log4j-api\2.17.1\log4j-api-2.17.1.jar;C:\Users\dell\.m2\repository\org\slf4j\jul-to-slf4j\1.7.33\jul-to-slf4j-1.7.33.jar;C:\Users\dell\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\dell\.m2\repository\org\yaml\snakeyaml\1.29\snakeyaml-1.29.jar;C:\Users\dell\.m2\repository\org\springframework\spring-aop\5.3.15\spring-aop-5.3.15.jar;C:\Users\dell\.m2\repository\org\springframework\security\spring-security-config\5.6.1\spring-security-config-5.6.1.jar;C:\Users\dell\.m2\repository\org\springframework\security\spring-security-web\5.6.1\spring-security-web-5.6.1.jar;C:\Users\dell\.m2\repository\org\springframework\spring-expression\5.3.15\spring-expression-5.3.15.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.6.3\spring-boot-starter-web-2.6.3.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.6.3\spring-boot-starter-json-2.6.3.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.13.1\jackson-databind-2.13.1.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.13.1\jackson-annotations-2.13.1.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.13.1\jackson-core-2.13.1.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.13.1\jackson-datatype-jdk8-2.13.1.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.13.1\jackson-datatype-jsr310-2.13.1.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.13.1\jackson-module-parameter-names-2.13.1.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.6.3\spring-boot-starter-tomcat-2.6.3.jar;C:\Users\dell\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.56\tomcat-embed-core-9.0.56.jar;C:\Users\dell\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.56\tomcat-embed-el-9.0.56.jar;C:\Users\dell\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.56\tomcat-embed-websocket-9.0.56.jar;C:\Users\dell\.m2\repository\org\springframework\spring-web\5.3.15\spring-web-5.3.15.jar;C:\Users\dell\.m2\repository\org\springframework\spring-webmvc\5.3.15\spring-webmvc-5.3.15.jar;C:\Users\dell\.m2\repository\mysql\mysql-connector-java\8.0.28\mysql-connector-java-8.0.28.jar;C:\Users\dell\.m2\repository\org\projectlombok\lombok\1.18.22\lombok-1.18.22.jar;C:\Users\dell\.m2\repository\org\springframework\spring-core\5.3.15\spring-core-5.3.15.jar;C:\Users\dell\.m2\repository\org\springframework\spring-jcl\5.3.15\spring-jcl-5.3.15.jar;C:\Users\dell\.m2\repository\org\springframework\security\spring-security-core\5.6.1\spring-security-core-5.6.1.jar;C:\Users\dell\.m2\repository\org\springframework\security\spring-security-crypto\5.6.1\spring-security-crypto-5.6.1.jar com.burrows.dailyWagers.DailyWagersApplication
  
    .   ____          _            __ _ _
   /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
  ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
   \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
    '  |____| .__|_| |_|_| |_\__, | / / / /
   =========|_|==============|___/=/_/_/_/
   :: Spring Boot ::                (v2.6.3)
  
  2022-02-04 23:09:16.239  INFO 1328 --- [           main] c.b.dailyWagers.DailyWagersApplication   : Starting DailyWagersApplication using Java 17.0.2 on DESKTOP-UNKQR00 with PID 1328 (C:\Users\dell\OneDrive\Desktop\dailyWagers\target\classes started by dell in C:\Users\dell\OneDrive\Desktop\dailyWagers)
  2022-02-04 23:09:16.246  INFO 1328 --- [           main] c.b.dailyWagers.DailyWagersApplication   : No active profile set, falling back to default profiles: default
  2022-02-04 23:09:19.421  INFO 1328 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
  2022-02-04 23:09:19.586  INFO 1328 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 114 ms. Found 1 JPA repository interfaces.
  2022-02-04 23:09:21.367  INFO 1328 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
  2022-02-04 23:09:21.408  INFO 1328 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
  2022-02-04 23:09:21.409  INFO 1328 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
  2022-02-04 23:09:21.621  INFO 1328 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
  2022-02-04 23:09:21.622  INFO 1328 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 5248 ms
  2022-02-04 23:09:21.765  WARN 1328 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controller': Unsatisfied dependency expressed through field 'workerService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.burrows.dailyWagers.service.WorkerService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  2022-02-04 23:09:21.771  INFO 1328 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
  2022-02-04 23:09:21.818  INFO 1328 --- [           main] ConditionEvaluationReportLoggingListener : 
  
  Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
  2022-02-04 23:09:21.881 ERROR 1328 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
  
  ***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  Field workerService in com.burrows.dailyWagers.controller.Controller required a bean of type 'com.burrows.dailyWagers.service.WorkerService' 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.burrows.dailyWagers.service.WorkerService' in your configuration.
  
  
  Process finished with exit code 1
  </code></pre>
  <p><strong>Controller.java</strong></p>
  <pre><code>package com.burrows.dailyWagers.controller;
  
  import com.burrows.dailyWagers.model.Worker;
  import com.burrows.dailyWagers.service.WorkerService;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.http.HttpStatus;
  import org.springframework.http.ResponseEntity;
  import org.springframework.web.bind.annotation.*;
  
  import java.util.List;
  
  @RestController
  @RequestMapping(&quot;/workers&quot;)
  public class Controller {
  
      @Autowired
      private WorkerService workerService;
  
      @GetMapping(&quot;/{workerType}&quot;)
      public List&lt;Worker&gt; getWorkers(@PathVariable String workerType){
          return this.workerService.getWorkers(workerType);
      }
  
      @GetMapping(&quot;/{id}&quot;)
      public Worker getWorker(@PathVariable Long id){
          return (Worker) this.workerService.getWorkers(String.valueOf(id));
      }
  
      @PostMapping(&quot;/{worker}&quot;)
      public void postWorker(@PathVariable Worker worker){
          this.workerService.postWorker(worker);
      }
  
      @PutMapping(&quot;/{worker}&quot;)
      public void updateWorker(@PathVariable Worker worker){
          this.workerService.updateWorker(worker);
      }
  
      @DeleteMapping(&quot;/{id}&quot;)
      public ResponseEntity&lt;HttpStatus&gt; deleteWorker(@PathVariable Long id){
          try {
              this.workerService.deleteWorker(id);
              return new ResponseEntity&lt;&gt;(HttpStatus.OK);
          }
          catch(Exception e){
              return new ResponseEntity&lt;&gt;(HttpStatus.INTERNAL_SERVER_ERROR);
          }
      }
  }
  </code></pre>
  <p><strong>WorkerService.java</strong></p>
  <pre><code>package com.burrows.dailyWagers.service;
  
  import com.burrows.dailyWagers.model.Worker;
  import org.springframework.stereotype.Service;
  
  import java.util.List;
  
  @Service
  public interface WorkerService {
      public List&lt;Worker&gt; getWorkers(String workerType);
      public Worker getWorker(Long id);
      public void postWorker(Worker worker);
      public void deleteWorker(Long id);
      public void updateWorker(Worker worker);
  }
  </code></pre>
  <p><strong>WorkerServiceImpl</strong></p>
  <pre><code>package com.burrows.dailyWagers.service;
  
  import com.burrows.dailyWagers.model.Worker;
  import com.burrows.dailyWagers.repository.WorkerRepository;
  import org.springframework.beans.factory.annotation.Autowired;
  
  import java.util.List;
  
  public class WorkerServiceImpl implements WorkerService{
      @Autowired
      private WorkerRepository workerRepository;
  
      public List&lt;Worker&gt; getWorkers(String workerType) {
          return workerRepository.findAll();
      }
  
      public Worker getWorker(Long id) {
          return workerRepository.getById(id);
      }
  
      public void postWorker(Worker worker) {
          workerRepository.save(worker);
      }
  
      public void deleteWorker(Long id) {
          Worker workerToBeDeleted = workerRepository.getById(id);
          workerRepository.delete(workerToBeDeleted);
      }
  
      public void updateWorker(Worker worker) {
          workerRepository.save(worker);
      }
  }
  </code></pre>
  <p><strong>WorkerRepository.java</strong></p>
  <pre><code>package com.burrows.dailyWagers.repository;
  
  import com.burrows.dailyWagers.model.Worker;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  
  @Repository
  public interface WorkerRepository extends JpaRepository&lt;Worker,Long&gt; {
  }
  </code></pre>
  <p><strong>Worker.java</strong></p>
  <pre><code>package com.burrows.dailyWagers.model;
  
  import lombok.AllArgsConstructor;
  import lombok.Builder;
  import lombok.Data;
  import lombok.NoArgsConstructor;
  import org.springframework.format.annotation.DateTimeFormat;
  
  import javax.persistence.*;
  
  import java.time.LocalDate;
  import java.util.List;
  
  @Data
  @AllArgsConstructor
  @NoArgsConstructor
  @Entity
  @Builder
  public class Worker {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      private String workerType;
      private String servicesOffered;
      private LocalDate availability;
      private Integer rating;
  }
  </code></pre>
  <p><strong>application.properties</strong></p>
  <pre><code>server.port=8081
  
  #mysql configuration
  spring.datasource.url=jdbc:mysql://localhost:3306/maid-app-db
  spring.datasource.username=root
  spring.datasource.password=5856
  spring.datasource.driverClassName=com.mysql.jdbc.Driver
  
  #hibernate configuration
  spring.jpa.hibernate.ddl-auto=update
  spring.jpa.show-sql=true
  </code></pre>
  <p><strong>pom.xml</strong></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 https://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.6.3&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.burrows&lt;/groupId&gt;
      &lt;artifactId&gt;dailyWagers&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;dailyWagers&lt;/name&gt;
      &lt;description&gt;daily wagers web application&lt;/description&gt;
      &lt;properties&gt;
          &lt;java.version&gt;11&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-security&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;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
              &lt;optional&gt;true&lt;/optional&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;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&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;configuration&gt;
                      &lt;excludes&gt;
                          &lt;exclude&gt;
                              &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
                              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
                          &lt;/exclude&gt;
                      &lt;/excludes&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>