title: Maven build fails: package does not exist
body: <p>I'm having a strange problem where I have one maven project that has a dependency on another maven project (both are mine) and I'm getting a compilation error complaining that packages don't exist - even though they do.</p>
  <pre><code>[INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time:  10.424 s
  [INFO] Finished at: 2020-12-22T07:32:51-05:00
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project e1-task-info2: Compilation failure: Compilation failure:
  [ERROR] /C:/Users/jgagnon/workspace/java/e1-task-info2/src/main/java/com/mycompany/e1tasks/backend/util/ExcelFileIngester.java:[10,42] package com.mycompany.exceljson.converter does not exist
  [ERROR] /C:/Users/jgagnon/workspace/java/e1-task-info2/src/main/java/com/mycompany/e1tasks/backend/util/ExcelFileIngester.java:[11,37] package com.mycompany.exceljson.pojo does not exist
  [ERROR] /C:/Users/jgagnon/workspace/java/e1-task-info2/src/main/java/com/mycompany/e1tasks/backend/util/ExcelFileIngester.java:[12,37] package com.mycompany.exceljson.pojo does not exist
  </code></pre>
  <p>I've done research (including in this forum) and found numerous items on this issue. I've taken some of the advice found, but it still doesn't work. I don't understand what I'm doing wrong.</p>
  <p>Here's the scenario:</p>
  <p>Project A provides functionality that Project B needs to use.</p>
  <p>Project A pom.xml:</p>
  <pre><code>&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;groupId&gt;com.mycompany&lt;/groupId&gt;
    &lt;artifactId&gt;excel-to-json&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
    &lt;name&gt;Excel to JSON Converter&lt;/name&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.3.3.RELEASE&lt;/version&gt;
    &lt;/parent&gt;
  
    &lt;properties&gt;
      &lt;java.version&gt;11&lt;/java.version&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
  
      &lt;commons-io.version&gt;2.6&lt;/commons-io.version&gt;
      &lt;commons-cli.version&gt;1.4&lt;/commons-cli.version&gt;
      &lt;org.apache.poi.version&gt;4.1.2&lt;/org.apache.poi.version&gt;
    &lt;/properties&gt;
  
    &lt;pluginRepositories&gt;
      &lt;pluginRepository&gt;
        &lt;id&gt;central&lt;/id&gt;
        &lt;url&gt;https://repo1.maven.org/maven2/&lt;/url&gt;
        &lt;snapshots&gt;
          &lt;enabled&gt;false&lt;/enabled&gt;
        &lt;/snapshots&gt;
      &lt;/pluginRepository&gt;
    &lt;/pluginRepositories&gt;
  
    &lt;repositories&gt;
      &lt;repository&gt;
        &lt;id&gt;central&lt;/id&gt;
        &lt;url&gt;https://repo1.maven.org/maven2/&lt;/url&gt;
        &lt;snapshots&gt;
          &lt;enabled&gt;false&lt;/enabled&gt;
        &lt;/snapshots&gt;
      &lt;/repository&gt;
    &lt;/repositories&gt;
  
    &lt;dependencies&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
        &lt;exclusions&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-logging&lt;/artifactId&gt;
          &lt;/exclusion&gt;
        &lt;/exclusions&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-log4j2&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
        &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
        &lt;artifactId&gt;poi&lt;/artifactId&gt;
        &lt;version&gt;${org.apache.poi.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
        &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
        &lt;version&gt;${org.apache.poi.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;commons-io&lt;/groupId&gt;
        &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
        &lt;version&gt;${commons-io.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;commons-cli&lt;/groupId&gt;
        &lt;artifactId&gt;commons-cli&lt;/artifactId&gt;
        &lt;version&gt;${commons-cli.version}&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;executions&gt;
            &lt;execution&gt;
              &lt;goals&gt;
                &lt;goal&gt;repackage&lt;/goal&gt;
              &lt;/goals&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  <p>Project B pom.xml:</p>
  <pre><code>&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;groupId&gt;com.mycompany&lt;/groupId&gt;
    &lt;artifactId&gt;e1-task-info2&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&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.3.3.RELEASE&lt;/version&gt;
    &lt;/parent&gt;
  
    &lt;packaging&gt;jar&lt;/packaging&gt;
  
    &lt;properties&gt;
      &lt;java.version&gt;11&lt;/java.version&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
    &lt;/properties&gt;
  
    &lt;pluginRepositories&gt;
      &lt;pluginRepository&gt;
        &lt;id&gt;central&lt;/id&gt;
        &lt;url&gt;https://repo1.maven.org/maven2/&lt;/url&gt;
        &lt;snapshots&gt;
          &lt;enabled&gt;false&lt;/enabled&gt;
        &lt;/snapshots&gt;
      &lt;/pluginRepository&gt;
    &lt;/pluginRepositories&gt;
  
    &lt;repositories&gt;
      &lt;repository&gt;
        &lt;id&gt;central&lt;/id&gt;
        &lt;url&gt;https://repo1.maven.org/maven2/&lt;/url&gt;
        &lt;snapshots&gt;
          &lt;enabled&gt;false&lt;/enabled&gt;
        &lt;/snapshots&gt;
      &lt;/repository&gt;
    &lt;/repositories&gt;
  
    &lt;dependencies&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
        &lt;exclusions&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-logging&lt;/artifactId&gt;
          &lt;/exclusion&gt;
        &lt;/exclusions&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-log4j2&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-devtools&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-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;com.h2database&lt;/groupId&gt;
        &lt;artifactId&gt;h2&lt;/artifactId&gt;
        &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;javax.validation&lt;/groupId&gt;
        &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
        &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;!-- The dependency --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.mycompany&lt;/groupId&gt;
        &lt;artifactId&gt;excel-to-json&lt;/artifactId&gt;
        &lt;version&gt;0.0.1-SNAPSHOT&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;executions&gt;
            &lt;execution&gt;
              &lt;goals&gt;
                &lt;goal&gt;repackage&lt;/goal&gt;
              &lt;/goals&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  <p>When I build my maven projects I almost always use <code>mvn clean install</code>. I've gone as far as completely removing my <code>~/.m2/repository</code> and rebuilding, but it still fails.</p>