title: How to Register beans from all sub packages in Spring boot app?
body: <p>I am creating new <code>spring boot</code> + <code>jpa</code> + <code>thymeleaf</code> application, I am using many modules which are placed in sub packages. I have structure like <code>ge.my.project</code> where is placed my main class with <code>@SpringBootApplication</code> and under this <code>package</code> I have sub packages <code>ge.my.project.dao</code>,<code>ge.my.project.service</code>,<code>ge.my.project.controller</code> and so on  where are placed my beans.<code>@SpringBootApplication</code> scans only beans under base(<code>ge.my.project</code>) package but I want to scan <code>beans</code> from all sub packages.</p>
  
  <p>I tried many variants to scan <code>sub packages</code> : </p>
  
  <pre><code>@ComponentScan(basePackages = {"ge.my.project.controller","ge.my.project.service","ge.my.project.configuration"})
  </code></pre>
  
  <p>and</p>
  
  <p><code>@ComponentScan({"ge.my.project.controller","ge.my.project.service","ge.my.proj
  ect.configuration"})</code></p>
  
  <p>and</p>
  
  <p><code>@ComponentScan("ge.my.project.*")</code></p>
  
  <p>but nothing works , When I am trying to inject beans using <code>@Autowired</code> 
  I am getting error like this <code>Consider defining a bean of type 'ge.my.project.service.ServiceTypeService' in your configuration.</code></p>
  
  <p>Here is my main class </p>
  
  <pre><code>package ge.my.project;
  
  import ge.ufc.inhouseProjects.controller.ServiceTypeController;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.autoconfigure.domain.EntityScan;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  
  
   @SpringBootApplication
  //@ComponentScan(basePackages = {"ge.my.project.controller","ge.my.project.service","ge.my.project.configuration"})
  @ComponentScan({"ge.my.project.*"})
  @EntityScan({"ge.my.project.entity"})
  @EnableJpaRepositories("ge.my.project.dao")
  public class InhouseProjectsApplication {
  
  public static void main(String[] args) {
      /*ApplicationContext applicationContext = */SpringApplication.run(InhouseProjectsApplication.class, args);
  }
  
  }
  </code></pre>
  
  <p>Here is my full project <a href="https://github.com/JavaGeoGroup/inhouseProjects.git" rel="nofollow noreferrer">https://github.com/JavaGeoGroup/inhouseProjects.git</a></p>
  
  <p>Which is the clearest way to scan all project beans in spring boot application? </p>