0

I've created two projects, one is an API (I'll call it search-api) to elasticsearch and the other an API (persistence-api) to postgreSQL, I need to have search-api as an dependency in persistence-api.

I fallowed the docs and I've watched some videos, but nothing seems to work when I'm performing the maven command "install -D skipTests"

Here's my files:

search-api's pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.fatec.stacktec</groupId>
    <artifactId>search-api</artifactId>
    <version>0.0.3-SNAPSHOT</version>
    <name>search-api</name>
    <description>Completeltion project of the Systems Development Analysis course.</description>
    <properties>
        <java.version>11</java.version>
        <github.global.server>github</github.global.server>
    </properties>
    
    
    <repositories>
        <repository>
            <id>github</id>
            <url>https://maven.pkg.github.com/isaqueChaves/maven-repository</url>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>
    
    <distributionManagement>
        <repository>
            <id>github</id>
            <name>GitHub isaqueChaves Apache Maven Packages</name>
            <url>https://maven.pkg.github.com/isaqueChaves/maven-repository</url>
        </repository>
    </distributionManagement>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>     
                <configuration>
                    <source>11</source>
                    <forceJavacCompilerUse>true</forceJavacCompilerUse>
                </configuration>           
            </plugin>
        </plugins>
    </build>

</project>

persistence-api's pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.fatec.stacktec</groupId>
    <artifactId>persistence-api</artifactId>
    <version>0.0.3-SNAPSHOT</version>
    <name>persistence-api</name>
    <description>Persistence API for relational and NoSQL DB</description>
    <properties>
        <java.version>11</java.version>
        <stacktec-search-api.version>0.0.3-SNAPSHOT</stacktec-search-api.version>       
    </properties>   
    
    <dependencies>
        <dependency>
          <groupId>com.fatec.stacktec</groupId>
          <artifactId>search-api</artifactId>
          <version>0.0.3-SNAPSHOT</version>
        </dependency>
   </dependencies>

    <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <repository>
            <id>github</id>
            <url>https://maven.pkg.github.com/isaqueChaves/maven-repository</url>               
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>        
        </repository>
    </repositories>
    
    <distributionManagement>
        <snapshotRepository>
            <id>github</id>
            <url>https://maven.pkg.github.com/isaqueChaves/maven-repository</url>
        </snapshotRepository>
        <repository>
            <id>github</id>
            <name>GitHub isaqueChaves Apache Maven Packages</name>
            <url>https://maven.pkg.github.com/isaqueChaves/maven-repository</url>
        </repository>
    </distributionManagement>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>     
                <configuration>
                    <forceJavacCompilerUse>true</forceJavacCompilerUse>
                </configuration>           
            </plugin>
        </plugins>
    </build>
    
</project>

Maven settings.xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <activeProfiles>
    <activeProfile>github</activeProfile>
  </activeProfiles>
  
  <profiles>
  
    <profile>
      <id>github</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
        </repository>
        <repository>
          <id>github</id>
          <url>https://maven.pkg.github.com/isaqueChaves/maven-repository</url>        
        </repository>
      </repositories>
    </profile>
  </profiles>

  <servers>
    <server>
      <id>github</id>
      <username>isaquechaves</username>
      <password>>mytoken</password>
    </server>
  </servers>
</settings>

And here's the output when I run "maven install -D skipTests":

 Downloading from : https://repo1.maven.org/maven2/com/fatec/stacktec/search-api/0.0.3-SNAPSHOT/search-api-0.0.3-20230409.024122-1.pom
 Downloading from : https://maven.pkg.github.com/isaqueChaves/maven-repository/com/fatec/stacktec/search-api/0.0.3-SNAPSHOT/search-api-0.0.3-20230409.024122-1.pom
Downloaded from : https://maven.pkg.github.com/isaqueChaves/maven-repository/com/fatec/stacktec/search-api/0.0.3-SNAPSHOT/search-api-0.0.3-20230409.024122-1.pom (3.1 kB at 3.3 kB/s)
 Downloading from : https://maven.pkg.github.com/isaqueChaves/maven-repository/com/fatec/stacktec/search-api/0.0.3-SNAPSHOT/search-api-0.0.3-20230409.024122-1.jar
Downloaded from : https://maven.pkg.github.com/isaqueChaves/maven-repository/com/fatec/stacktec/search-api/0.0.3-SNAPSHOT/search-api-0.0.3-20230409.024122-1.jar (63 MB at 14 MB/s)

[1m--- [0;32mmaven-resources-plugin:3.1.0:resources[m [1m(default-resources)[m @ [36mpersistence-api Using 'UTF-8' encoding to copy filtered resources.
 Copying 1 resource
 Copying 1 resource

[1m--- [0;32mmaven-compiler-plugin:3.8.1:compile[m [1m(default-compile)[m @ [36mpersistence-api[0;
Changes detected - recompiling the module!
Compiling 29 source files to C:\Users\Administrador\Documents\workspace-spring-tool-suite-4-4.18.0.RELEASE\persistence-api\target\classes
-------------------------------------------------------------
COMPILATION ERROR : 
 -------------------------------------------------------------
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/model/user/Role.java:[18,48] package com.fatec.stacktec.searchapi.holder.user does not exist
Failed to execute goal [32morg.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile[m  Compilation failure: 
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/model/user/Role.java:[18,48] package com.fatec.stacktec.searchapi.holder.user does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/model/user/UserInternal.java:[27,48] package com.fatec.stacktec.searchapi.enumeration does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/model/user/UserInternal.java:[28,43] package com.fatec.stacktec.searchapi.holder does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/model/user/Role.java:[45,25] cannot find symbol
symbol:   class RoleHolder
location: class com.fatec.stacktec.persistenceapi.model.user.Role
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/model/user/UserInternal.java:[69,17] cannot find symbol
symbol:   class SemestreType
location: class com.fatec.stacktec.persistenceapi.model.user.UserInternal
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/model/user/UserInternal.java:[73,25] cannot find symbol
symbol:   class UserInternalHolder
location: class com.fatec.stacktec.persistenceapi.model.user.UserInternal
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/model/user/UserInternal.java:[69,30] cannot find symbol
symbol:   class SemestreType
location: class com.fatec.stacktec.persistenceapi.model.user.UserInternal
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/model/user/UserInternal.java:[34,1] cannot find symbol
symbol:   class SemestreType
location: class com.fatec.stacktec.persistenceapi.model.user.UserInternal
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/enumeration/EnvironmentType.java:[6,41] package com.fatec.stacktec.searchapi.util does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/RoleSearchServiceFacade.java:[13,48] package com.fatec.stacktec.searchapi.holder.user does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/RoleSearchServiceFacade.java:[14,52] package com.fatec.stacktec.searchapi.repository.user does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/RoleSearchServiceFacade.java:[15,43] package com.fatec.stacktec.searchapi.search does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/RoleSearchServiceFacade.java:[21,46] cannot find symbol
symbol: class ESBaseStoreServiceImpl
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/RoleSearchServiceFacade.java:[21,69] cannot find symbol
symbol: class RoleSearchRepository
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/RoleSearchServiceFacade.java:[21,91] cannot find symbol
symbol: class RoleHolder
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/RoleSearchServiceFacade.java:[47,25] cannot find symbol
symbol:   class RoleHolder
location: class com.fatec.stacktec.persistenceapi.search.facade.user.RoleSearchServiceFacade
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/UserInternalSearchServiceFacade.java:[13,43] package com.fatec.stacktec.searchapi.holder does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/UserInternalSearchServiceFacade.java:[14,52] package com.fatec.stacktec.searchapi.repository.user does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/UserInternalSearchServiceFacade.java:[15,43] package com.fatec.stacktec.searchapi.search does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/UserInternalSearchServiceFacade.java:[21,54] cannot find symbol
symbol: class ESBaseStoreServiceImpl
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/UserInternalSearchServiceFacade.java:[21,77] cannot find symbol
symbol: class UserInternalSearchRepository
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/UserInternalSearchServiceFacade.java:[21,107] cannot find symbol
symbol: class UserInternalHolder
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/search/facade/user/UserInternalSearchServiceFacade.java:[49,25] cannot find symbol
symbol:   class UserInternalHolder
location: class com.fatec.stacktec.persistenceapi.search.facade.user.UserInternalSearchServiceFacade
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/listener/user/RoleEntityListener.java:[11,48] package com.fatec.stacktec.searchapi.holder.user does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/listener/user/RoleEntityListener.java:[12,43] package com.fatec.stacktec.searchapi.search does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/listener/user/RoleEntityListener.java:[13,41] package com.fatec.stacktec.searchapi.util does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/listener/user/UserInternalEntityListener.java:[11,43] package com.fatec.stacktec.searchapi.holder does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/listener/user/UserInternalEntityListener.java:[12,43] package com.fatec.stacktec.searchapi.search does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/listener/user/UserInternalEntityListener.java:[13,41] package com.fatec.stacktec.searchapi.util does not exist
/C:/Users/Administrador/Documents/workspace-spring-tool-suite-4-4.18.0.RELEASE/persistence-api/src/main/java/com/fatec/stacktec/persistenceapi/configuration/FlywayMigrationConfig.java:[13,43] package com.fatec.stacktec.searchapi.search does not exist
[INFO] 30 errors 

All the imports comming from the search-api dependency failed

Thank you all in advance, because change the configuration of these snapshots will take many hours

  • I've tried to clean my local repositories in m2/repository
  • I've tried to perform the command mvn clean install -U -D skipTests
  • Obs.: It worked one time, but when I changed some stuffs in the code and generated a new snapshot, it started to give error
  • problem is in `com.fatec.stacktec.persistenceapi.model.user.Role` class. what is this? is this in your dependencies or this is part of your project classes? – Amir Azizkhani Apr 09 '23 at 04:50
  • This class (Role) is from the persistence-api, isn't from dependencies – Isaque Chaves Apr 09 '23 at 05:25
  • This is one of the 30 errors I'm facing from importing classes from the other project (search-api) – Isaque Chaves Apr 09 '23 at 05:25
  • I updated the question with all the errors, It seems a problem with my dependency, but in the log it says the download completed – Isaque Chaves Apr 09 '23 at 05:33
  • It's better to share your project in github. Probably you missed something that you don't mentioned it here – Amir Azizkhani Apr 09 '23 at 06:19
  • Both pom snippet is for `persistence-api` and the pom of `search-api` is missing. Please edit question and add missing pom snippet. – zforgo Apr 09 '23 at 06:26
  • I updated the question with the correct pom snippet. @AmirAzizkhani, here's the link for projects in Github: https://github.com/isaquechaves/persistence-api - https://github.com/isaquechaves/StackTec-API – Isaque Chaves Apr 09 '23 at 06:33
  • I forgot to add the link for the repo of snapshots: https://github.com/isaquechaves/maven-repository/packages/ – Isaque Chaves Apr 09 '23 at 06:39
  • before trying to install `persistence-api`, you need to install `search-api`. because these project aren't in the same parent module. I tested it and I didn't see any problem – Amir Azizkhani Apr 09 '23 at 07:15
  • @AmirAzizkhani, I installed search-api before trying to install persistence, but what I noticed, sometimes it works, but sometimes don't, I don't know what could be. When it happened, I try to clean the search-api project and persistence, and install search-api, and worked, I don't know if it's some problem with the cache, because sometimes it didn't work at all, and I have forced Maven update snapshots, then started to work after run clean and install in both projects – Isaque Chaves Apr 09 '23 at 16:00

2 Answers2

0

The class Role is not located in the package indicated in the code com.fatec.stacktec.searchapi.holder.user you should either change the package in the Role.java or place the file Role.java in the mentioned package.

rainman
  • 2,551
  • 6
  • 29
  • 43
  • The location of my class Role in persistence-API: package com.fatec.stacktec.persistenceapi.model.user; The location of the class RoleHolder wich it's imported: package com.fatec.stacktec.searchapi.holder.user; – Isaque Chaves Apr 09 '23 at 05:27
0

As @Amir Azizkhan said "before trying to install persistence-api, you need to install search-api. because these project aren't in the same parent module. I tested it and I didn't see any problem"

The problem seems resolved, probably some errors with Maven cache, my configs seem to be correct, so I'm closing this question, thank you all for helping me!