title: A module can not access JpaRepository interface that is in the other module
body: <p>I am using IntelliJ and Gradle for a sample project. There are two modules.</p>
  <ol>
  <li>demo-core module
  It has entity and repository classes. build.gradle file is like the below.</li>
  </ol>
  <pre><code>apply plugin: 'java'
  
  group 'com.example'
  version '0.0.1-SNAPSHOT'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      implementation 'com.h2database:h2:1.4.200'
      implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.5.3'
      testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
      testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
  }
  
  test {
      useJUnitPlatform()
  }
  </code></pre>
  <p>I added CustomerRepository class for Customer entity in demo-core module.</p>
  <pre><code>package example.springboot.entity;
  
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  
  @Repository
  public interface CustomerRepository extends JpaRepository&lt;Customer, Long&gt; {
  }
  </code></pre>
  <ol start="2">
  <li>demo-web module</li>
  </ol>
  <p>This is a web module and uses the repository interface like the below.</p>
  <pre><code>@SpringBootApplication
  public class DemoWebApp {
      public static void main(String[] args) {
          SpringApplication.run(DemoWebApp.class, args);
      }
      @Bean
      public CommandLineRunner demo(CustomerRepository repository) {
          return (args) -&gt; {
              // save a few customers
              repository.save(new Customer(&quot;Jack&quot;, &quot;Bauer&quot;));
              repository.save(new Customer(&quot;Chloe&quot;, &quot;O'Brian&quot;));
              repository.save(new Customer(&quot;Kim&quot;, &quot;Bauer&quot;));
              repository.save(new Customer(&quot;David&quot;, &quot;Palmer&quot;));
              repository.save(new Customer(&quot;Michelle&quot;, &quot;Dessler&quot;));
          };
      }
  }
  </code></pre>
  <p>This is build.gradle file for demo-web module.</p>
  <pre><code>plugins {
      id 'org.springframework.boot' version '2.5.3'
      id 'io.spring.dependency-management' version '1.0.11.RELEASE'
      id 'java'
  }
  
  group 'com.example'
  version '0.0.1-SNAPSHOT'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      implementation project(':demo-core')
      implementation 'org.springframework.boot:spring-boot-starter-web'
      testImplementation 'org.springframework.boot:spring-boot-starter-test'
      testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
      testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
  }
  
  test {
      useJUnitPlatform()
  }
  </code></pre>
  <p>but I can't use JpaRepsitory methods with this error.</p>
  <pre><code>/Users/dgkim/Downloads/demo/demo-web/src/main/java/example/springboot/DemoWebApp.java:19: error: cannot access JpaRepository
              repository.save(new Customer(&quot;Jack&quot;, &quot;Bauer&quot;));
                        ^
    class file for org.springframework.data.jpa.repository.JpaRepository not found
  </code></pre>
  <p>So, I created a new interface wrapping the CustomerRepository in demo-core module like this.</p>
  <pre><code>@Service
  public class CustomerFinder {
      @Autowired
      private CustomerRepository customerRepository;
  
      public Optional&lt;Customer&gt; findCustomer(Long id)   {
          return customerRepository.findById(id);
      }
  }
  </code></pre>
  <p>My Controller class uses the wrapper interface like the below.</p>
  <pre><code>@RestController
  public class CustomerController {
      @Autowired
      private CustomerFinder finder;
  
      @GetMapping(&quot;/customer/{id}&quot;)
      public String customer(@PathVariable Long id)  {
          Optional&lt;Customer&gt; customerOptional = finder.findCustomer(id);
          if(customerOptional.isPresent()) return &quot;find customer. &quot; + customerOptional.get().getLastName();
          else return &quot;no entity&quot;;
      }
  }
  </code></pre>
  <p>It works. JpaRepository methods can be accessed in the same module but demo-web module that has a dependency on demo-core can not access it. DemoWebApp class can access CustomerRepository interface itself but can not access the super interface (JpaRepository).</p>
  <p>How can I resolve this issue?</p>