Skip to content
Advertisement

Cannot resolve symbol, but the dependency is in local repo

I’ve been reading all similar problems with maven but I cannot seem to be able to fix it. The issue is the classic “Cannot resolve symbol ‘pippo'”, in which case pippo is part of

import com.pippo.device.manager.data.model.Device;

This class Device comes from this artifact that I have in my local repo

<dependency>
    <groupId>com.pippo</groupId>
    <artifactId>device.manager</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

Evidence that it is in the local repository

/mnt/c/Users/sanvegeta/.m2/repository$ find . -type f -name "*device.manager*" -ls
38228 -rwxrwxrwx   1 sanvegeta sanvegeta 39142700 Oct  1 09:00 ./com/pippo/device.manager/0.0.1-SNAPSHOT/device.manager-0.0.1-SNAPSHOT.jar
    4 -rwxrwxrwx   1 sanvegeta sanvegeta     1969 Oct  1 08:47 ./com/pippo/device.manager/0.0.1-SNAPSHOT/device.manager-0.0.1-SNAPSHOT.pom 

and evidence that this is the correct local repository

mvn help:evaluate -Dexpression=settings.localRepository | grep -v '[INFO]'
/mnt/c/Users/sanvegeta/.m2/repository                          

Just to give you a little bit of context: I’m working on a lab exercise and I created 2 microservices: com.pluto.user.manager and com.pippo.device.manager. They both expose CRUD REST API to work respectively on User and Device. Part of my exercise is to refer to the entity Device from another service (in this case from com.pluto.user.manager) so, in the user.manager, I created an API that is supposed to link the device to the user (it’s just adding an id to the user, nothing serious). And the compiler complains. I even tried to create a docker container with jdk, maven and git, and tried to compile there: same problem.

The class where the error appears is the following

package com.pluto.user.manager.controller;

import com.pippo.device.manager.data.model.Device; // problem here
import com.pluto.user.manager.data.model.User;
import com.pluto.user.manager.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/users")
public class UserController {

    @Autowired
    private UserService userService;
    
    //  various CRUD API here
    //  ...

    @PostMapping(path = "/{id}/link",  consumes = "application/json", produces = "application/json")
    public User link(@PathVariable String id, @RequestBody Device device) {
        return userService.linkToDevice(id, device.getId());
    }
}

Please, can you help me understand what am I doing wrong?

Edit 1: adding pom.xml of user.manager as requested

<?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.5.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.pluto</groupId>
    <artifactId>user.manager</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>user.manager</name>
    <description>User Manager Service</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>2.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.pippo</groupId>
            <artifactId>device.manager</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${project.parent.version}</version>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

and the output of “mvn clean package”

[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building user.manager 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ user.manager ---
[INFO] Deleting /mnt/e/Repository/GCP/exercise1/user.manager/target
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ user.manager ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ user.manager ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /mnt/e/Repository/GCP/exercise1/user.manager/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /mnt/e/Repository/GCP/exercise1/user.manager/src/main/java/com/pluto/user/manager/controller/UserController.java:[3,43] package com.pippo.device.manager.data.model does not exist
[ERROR] /mnt/e/Repository/GCP/exercise1/user.manager/src/main/java/com/pluto/user/manager/controller/UserController.java:[40,99] package com.pippo.device.manager.data.model does not exist
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 37.983 s
[INFO] Finished at: 2021-10-01T23:01:35+02:00
[INFO] Final Memory: 28M/100M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project user.manager: Compilation failure: Compilation failure: 
[ERROR] /mnt/e/Repository/GCP/exercise1/user.manager/src/main/java/com/pluto/user/manager/controller/UserController.java:[3,43] package com.pippo.device.manager.data.model does not exist
[ERROR] /mnt/e/Repository/GCP/exercise1/user.manager/src/main/java/com/pluto/user/manager/controller/UserController.java:[40,99] package com.pippo.device.manager.data.model does not exist
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

and output of jar -tvf /mnt/c/Users/sanvegeta/.m2/repository/com/pippo/device.manager/0.0.1-SNAPSHOT/device.manager-0.0.1-SNAPSHOT.jar

     0 Fri Oct 01 08:59:58 CEST 2021 META-INF/
   467 Fri Oct 01 08:59:58 CEST 2021 META-INF/MANIFEST.MF
     0 Fri Feb 01 00:00:00 CET 1980 org/
     0 Fri Feb 01 00:00:00 CET 1980 org/springframework/
     0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/
     0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/
  5871 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/ClassPathIndexFile.class
  6806 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/ExecutableArchiveLauncher.class
  3966 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/JarLauncher.class
  1483 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/LaunchedURLClassLoader$DefinePackageCallType.class
  1535 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/LaunchedURLClassLoader$UseFastConnectionExceptionsEnumeration.class
 11154 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/LaunchedURLClassLoader.class
  5932 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/Launcher.class
  1536 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/MainMethodRunner.class
   266 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/PropertiesLauncher$1.class
  1484 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/PropertiesLauncher$ArchiveEntryFilter.class
  8128 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/PropertiesLauncher$ClassPathArchives.class
  1953 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/PropertiesLauncher$PrefixMatchingArchiveFilter.class
 18267 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/PropertiesLauncher.class
  1750 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/WarLauncher.class
     0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/
   302 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/Archive$Entry.class
   511 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/Archive$EntryFilter.class
  4745 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/Archive.class
  6093 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive$AbstractIterator.class
  2180 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive$ArchiveIterator.class
  1857 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive$EntryIterator.class
  1269 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive$FileEntry.class
  2527 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive$SimpleJarFileArchive.class
  5346 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/ExplodedArchive.class
  2884 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/JarFileArchive$AbstractIterator.class
  1981 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/JarFileArchive$EntryIterator.class
  1081 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/JarFileArchive$JarFileEntry.class
  2528 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/JarFileArchive$NestedArchiveIterator.class
 10349 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/archive/JarFileArchive.class
     0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/
   485 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/RandomAccessData.class
   282 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/RandomAccessDataFile$1.class
  2680 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/RandomAccessDataFile$DataInputStream.class
  3259 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/RandomAccessDataFile$FileAccess.class
  4015 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/data/RandomAccessDataFile.class
     0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/
  1438 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/AbstractJarFile$JarFileType.class
   878 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/AbstractJarFile.class
  4976 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/AsciiBytes.class
   616 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/Bytes.class
   295 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryEndRecord$1.class
  3319 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64End.class
  2039 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryEndRecord$Zip64Locator.class
  5029 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryEndRecord.class
  6889 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryFileHeader.class
  4624 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryParser.class
   540 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/CentralDirectoryVisitor.class
   345 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/FileHeader.class
 13649 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/Handler.class
  3885 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarEntry.class
  1458 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarEntryCertification.class
   299 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarEntryFilter.class
  2299 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFile$1.class
  1299 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFile$JarEntryEnumeration.class
 16312 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFile.class
  1368 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries$1.class
  2258 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries$EntryIterator.class
  1281 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries$Offsets.class
  1338 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries$Zip64Offsets.class
  1334 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries$ZipOffsets.class
 17280 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileEntries.class
  3512 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarFileWrapper.class
   702 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarURLConnection$1.class
  4302 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarURLConnection$JarEntryName.class
  9440 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/JarURLConnection.class
  3559 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/StringSequence.class
  1813 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jar/ZipInflaterInputStream.class
     0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jarmode/
   293 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jarmode/JarMode.class
  2201 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jarmode/JarModeLauncher.class
  1292 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/jarmode/TestJarMode.class
     0 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/util/
  5174 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/util/SystemPropertyUtils.class
     0 Fri Oct 01 08:59:58 CEST 2021 BOOT-INF/
     0 Fri Oct 01 08:59:58 CEST 2021 BOOT-INF/classes/
     0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/
     0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/
     0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/
     0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/
     0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/controller/
     0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/data/
     0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/data/model/
     0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/repository/
     0 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/service/
     0 Fri Oct 01 08:59:56 CEST 2021 META-INF/maven/
     0 Fri Oct 01 08:59:56 CEST 2021 META-INF/maven/com.pippo/
     0 Fri Oct 01 08:59:56 CEST 2021 META-INF/maven/com.pippo/device.manager/
   804 Fri Oct 01 08:59:36 CEST 2021 BOOT-INF/classes/application.properties
   737 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/Application.class
  2433 Fri Oct 01 08:59:48 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/controller/DeviceController.class
  1617 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/data/model/Device.class
   364 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/repository/DeviceRepository.class
  3530 Fri Oct 01 08:59:46 CEST 2021 BOOT-INF/classes/com/pippo/device/manager/service/DeviceService.class
  1969 Fri Oct 01 08:47:32 CEST 2021 META-INF/maven/com.pippo/device.manager/pom.xml
    67 Fri Oct 01 08:59:56 CEST 2021 META-INF/maven/com.pippo/device.manager/pom.properties
     0 Fri Oct 01 08:59:58 CEST 2021 BOOT-INF/lib/
382204 Wed Sep 15 07:22:06 CEST 2021 BOOT-INF/lib/spring-aop-5.3.10.jar
2087074 Fri Feb 01 00:00:00 CET 1980 BOOT-INF/lib/aspectjweaver-1.9.7.jar
159222 Wed Mar 03 13:06:58 CET 2021 BOOT-INF/lib/HikariCP-4.0.3.jar
427946 Wed Sep 15 07:22:12 CEST 2021 BOOT-INF/lib/spring-jdbc-5.3.10.jar
 15392 Fri Aug 02 22:14:54 CEST 2019 BOOT-INF/lib/jakarta.transaction-api-1.3.3.jar
164392 Fri Aug 02 16:59:46 CEST 2019 BOOT-INF/lib/jakarta.persistence-api-2.2.3.jar
7351256 Mon May 24 12:01:22 CEST 2021 BOOT-INF/lib/hibernate-core-5.4.32.Final.jar
 60911 Tue May 25 13:11:32 CEST 2021 BOOT-INF/lib/jboss-logging-3.4.2.Final.jar
782774 Thu Mar 19 13:33:58 CET 2020 BOOT-INF/lib/javassist-3.27.0-GA.jar
3510658 Tue Mar 09 15:35:56 CET 2021 BOOT-INF/lib/byte-buddy-1.10.22.jar
445288 Wed Sep 06 11:15:04 CEST 2006 BOOT-INF/lib/antlr-2.7.7.jar
202552 Fri Jan 22 15:15:02 CET 2021 BOOT-INF/lib/jandex-2.2.3.Final.jar
 67815 Sat Oct 19 22:46:30 CEST 2019 BOOT-INF/lib/classmate-1.5.1.jar
323630 Sun Apr 12 12:05:40 CEST 2020 BOOT-INF/lib/dom4j-2.1.3.jar
 78948 Fri Oct 30 16:06:46 CET 2020 BOOT-INF/lib/hibernate-commons-annotations-5.1.2.Final.jar
1019255 Tue Jul 20 13:39:34 CEST 2021 BOOT-INF/lib/jaxb-runtime-2.3.5.jar
 72008 Tue Jul 20 13:39:08 CEST 2021 BOOT-INF/lib/txw2-2.3.5.jar
 29807 Thu Mar 18 15:25:56 CET 2021 BOOT-INF/lib/istack-commons-runtime-3.0.12.jar
 68453 Thu Feb 20 18:37:08 CET 2020 BOOT-INF/lib/jakarta.activation-1.2.2.jar
375623 Fri Sep 17 09:20:56 CEST 2021 BOOT-INF/lib/spring-data-jpa-2.5.5.jar
1260499 Fri Sep 17 09:19:30 CEST 2021 BOOT-INF/lib/spring-data-commons-2.5.5.jar
204085 Wed Sep 15 07:22:22 CEST 2021 BOOT-INF/lib/spring-orm-5.3.10.jar
1267911 Wed Sep 15 07:22:10 CEST 2021 BOOT-INF/lib/spring-context-5.3.10.jar
333421 Wed Sep 15 07:22:10 CEST 2021 BOOT-INF/lib/spring-tx-5.3.10.jar
696648 Wed Sep 15 07:22:04 CEST 2021 BOOT-INF/lib/spring-beans-5.3.10.jar
 41513 Tue Jul 20 13:56:20 CEST 2021 BOOT-INF/lib/slf4j-api-1.7.32.jar
 47229 Wed Sep 15 07:22:24 CEST 2021 BOOT-INF/lib/spring-aspects-5.3.10.jar
1392938 Thu Sep 23 07:11:26 CEST 2021 BOOT-INF/lib/spring-boot-2.5.5.jar
1564860 Thu Sep 23 07:10:20 CEST 2021 BOOT-INF/lib/spring-boot-autoconfigure-2.5.5.jar
292027 Fri Sep 10 00:27:02 CEST 2021 BOOT-INF/lib/logback-classic-1.2.6.jar
472431 Fri Sep 10 00:15:50 CEST 2021 BOOT-INF/lib/logback-core-1.2.6.jar
 17762 Sat Mar 06 22:13:24 CET 2021 BOOT-INF/lib/log4j-to-slf4j-2.14.1.jar
300365 Sat Mar 06 22:11:34 CET 2021 BOOT-INF/lib/log4j-api-2.14.1.jar
  4589 Tue Jul 20 13:55:30 CEST 2021 BOOT-INF/lib/jul-to-slf4j-1.7.32.jar
 25058 Fri Aug 02 11:08:52 CEST 2019 BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar
326914 Mon Feb 22 05:55:56 CET 2021 BOOT-INF/lib/snakeyaml-1.28.jar
1515991 Fri Aug 27 00:33:48 CEST 2021 BOOT-INF/lib/jackson-databind-2.12.5.jar
 75704 Thu Aug 26 23:31:22 CEST 2021 BOOT-INF/lib/jackson-annotations-2.12.5.jar
365536 Thu Aug 26 23:57:50 CEST 2021 BOOT-INF/lib/jackson-core-2.12.5.jar
 34438 Fri Aug 27 01:10:42 CEST 2021 BOOT-INF/lib/jackson-datatype-jdk8-2.12.5.jar
120362 Fri Aug 27 01:10:24 CEST 2021 BOOT-INF/lib/jackson-datatype-jsr310-2.12.5.jar
  9440 Fri Aug 27 01:10:34 CEST 2021 BOOT-INF/lib/jackson-module-parameter-names-2.12.5.jar
3429357 Mon Sep 06 23:09:00 CEST 2021 BOOT-INF/lib/tomcat-embed-core-9.0.53.jar
255802 Mon Sep 06 23:09:00 CEST 2021 BOOT-INF/lib/tomcat-embed-el-9.0.53.jar
277386 Mon Sep 06 23:09:00 CEST 2021 BOOT-INF/lib/tomcat-embed-websocket-9.0.53.jar
1633568 Wed Sep 15 07:22:16 CEST 2021 BOOT-INF/lib/spring-web-5.3.10.jar
1027620 Wed Sep 15 07:22:26 CEST 2021 BOOT-INF/lib/spring-webmvc-5.3.10.jar
288281 Wed Sep 15 07:22:04 CEST 2021 BOOT-INF/lib/spring-expression-5.3.10.jar
 93107 Tue Dec 19 16:23:24 CET 2017 BOOT-INF/lib/validation-api-2.0.1.Final.jar
2303679 Mon Oct 14 09:19:50 CEST 2019 BOOT-INF/lib/h2-1.4.200.jar
115638 Mon Jan 27 09:34:38 CET 2020 BOOT-INF/lib/jakarta.xml.bind-api-2.3.3.jar
 46613 Thu Feb 20 18:37:30 CET 2020 BOOT-INF/lib/jakarta.activation-api-1.2.2.jar
1479606 Fri Feb 01 00:00:00 CET 1980 BOOT-INF/lib/spring-core-5.3.10.jar
 24436 Wed Sep 15 07:21:48 CEST 2021 BOOT-INF/lib/spring-jcl-5.3.10.jar
 29277 Fri Feb 01 00:00:00 CET 1980 BOOT-INF/lib/spring-boot-jarmode-layertools-2.5.5.jar
  2403 Fri Oct 01 09:00:00 CEST 2021 BOOT-INF/classpath.idx
   212 Fri Oct 01 09:00:00 CEST 2021 BOOT-INF/layers.idx

Edit 2 (closer to the resolution) As Stephen suggested, the internal structure of the generated jar file seems wrong. I crafted an alternative jar file with the paths that don’t start with BOOT-INF/classes, and the user.manager service compiles and runs just fine. Now the question is: how do I instruct spring boot to either generate the correct structure or to “see” the classes?

Advertisement

Answer

I think you have the wrong dependency. By my reading of the jar -tf output, that looks like a SpringBoot executable JAR file. The Device.class file is there, but its path is not right … for a normal Java compiler to resolve it:

This:

 BOOT-INF/classes/com/pippo/device/manager/data/model/Device.class 

needs to be this:

 com/pippo/device/manager/data/model/Device.class

I can’t find any trace of “com.pippo.*” using Google, so I am guessing that this is a private project.

But if you want use the com.pippo.device.manager classes in other modules, you need to modify its POM file to generate a regular JAR, and use that as the dependency.

One suggestion would be to refactor the existing com.pippo / device.manager project into a SpringBoot project and a (new) regular “library” JAR project, with the former depending on the latter. Put the classes that you want to reuse in com.pluto / project.manager into the “library” project.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement