Maven compilation error: package does not exist

I am trying to add maven support to an existing enterprise project. This is a multi-module project, and the first 2 modules compile and pack without problems, but I encountered a compilation error. I am trying to use the same dependency in multiple modules. My structure:

> + parent
>    - pom.xml
>    - module-1
>    -   pom.xml
>    - module-2  (Depends on module-1)
>    -   pom.xml
>    - module-3
>    -   pom.xml (Depends on both modules 1 and 2)

I'm with a project open on Eclipse and it shows no errors. When I run mvn clean installfrom parent, it successfully installs both modules 1 and 2, but does not work on module 3, saying that package xxx.yyy does not existand Cannot find symbol XXXYYY. Package xxx.yyy and symbol XXXYYY are in the bank, which is indicated in the dependencies of both modules 2 and 3.

Since both modules depend on the same jar, I tried to add the dependency only to module 2, and I believe that module 3 should see this because of transitive dependencies, but it could not see the package. Therefore, I tried to add a dependency to both modules 2 and 3 pumps, and the problem remained.

I already checked / tried:

  • The requested jar is indicated in my dependencies. I ran the following command, and after that I can see the required .jar file in the dependency list:mvn dependency:copy-dependencies
  • As I said above, I tried to include my class path through a transitive dependency and refer to it directly on my pom, and both solutions did not work.
  • I tried to delete my entire repository and load everything again, and also did not work.

, 3 2 lib, 2.

2 3. - .

-2

<project xmlns="http://maven.apache.org/POM/4.0.0" ... >  
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.company</groupId>
    <artifactId>parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <artifactId>Module2</artifactId>    
  <dependencies>

      <dependency>
          <groupId>com.company</groupId>
          <artifactId>Module1</artifactId>
          <version>0.0.1-SNAPSHOT</version>
      </dependency>         

    <dependency>
        <groupId>com.company</groupId>
        <artifactId>SharedArtifact</artifactId>
        <version>1.1</version>
     </dependency>

    ...

-3

<project xmlns="http://maven.apache.org/POM/4.0.0" ... >  
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.company</groupId>
    <artifactId>parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <artifactId>Module3</artifactId>    
  <dependencies>

      <dependency>
          <groupId>com.company</groupId>
          <artifactId>Module2</artifactId>
          <version>0.0.1-SNAPSHOT</version>
      </dependency>         

    <!--<dependency>
        <groupId>com.company</groupId>
        <artifactId>SharedArtifact</artifactId>
        <version>1.1</version>
     </dependency>-->

    ...

, , "SharedArtifact". 2, package does not exist SharedArtifact. package does not exist Module2.

, - , 3 .

Java 1.6.0_29 Maven 3.0.5. Java 7, Java 6. Maven, Maven java 7 .

1:

:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] \Users\usuario\Documents\workspaces\myworkspace\qa\Module3\src\com\company\sharedartifact\package\SomeClass.java:[8,55] 
package com.company.sharedartifact.package  does not exist
[ERROR] \Users\usuario\Documents\workspaces\myworkspace\qa\Module3\src\com\company\sharedartifact\package\SomeClass.java:[9,55] 
package com.company.sharedartifact.package does not exist
[ERROR] \Users\usuario\Documents\workspaces\myworkspace\qa\Module3\src\com\company\sharedartifact\package\SomeClass.java:[17,85] 
cannot find symbol
symbol  : class SomeOtherClass

-X - , - , .

2:

, mvn clean install, . mvn clean, ( Eclipse) Maven Update project, `mvn install, !

, , , - classpath. Weblogic Portal, (, , ) Eclipse. , . , , , , .

+4
1

, , @user944849 Maven 3.3.9 JDK 1.8.0_60, POM, 1.6.

<plugin>
  <artifactId>maven-compiler-plugin</artifactId>        
  <configuration>
     <source>1.6</source>
     <target>1.6</target>
  </configuration>
</plugin>

3 , 4 5 - JRockit libs. , , .

, , Maven, . - , , 2 , . , 3.3.9 .

0

Source: https://habr.com/ru/post/1674027/


All Articles