Java Maven Cannot Find Symbol on compile, but runs ok on debug

61 views Asked by At

I have a proyect in microservices with a commons library which holds all entities and some other classes, it compiles and installs without any trouble or error. BUT! in my microservices where i DO have this commons included in the pom.xml, maven just can't find the classes.... (when compiling) all microservices run without errors on debug

I'm using vscode 1.87.2 and Java 21 (build 21.0.2+13) with Apache Maven 3.8.7 (b89d5959fcde851dcb1c8946a785a163f14e1e29) and Spring Boot 3.2.2 on Manjaro Linux

mi commons is the first listed dependency on each microservice's pom file as:

<dependency>
   <groupId>cl.mein.project</groupId>
   <artifactId>sof-be-commons</artifactId>
   <version>0.0.1</version>
</dependency>

on every *Application class i have these annotations:

@SpringBootApplication
@EntityScan({ "cl.mein.project.sofbecommons" })
@EnableDiscoveryClient
@EnableFeignClients

and the imports are as follow:

import cl.mein.project.commons.models.Direccion;

as for the package for class Direccion in the commons:

package cl.mein.project.commons.models;

Everything runs flawlessly on debug but whenever I run mvn clean compile, I get this error, for every class from commons.

Compilation failure: Compilation failure: [ERROR] /home/ph1l/Workspace/SOFERTAS/sof-be-direcciones/src/main/java/cl/mein/project/sofbedirecciones/infraestructure/adapters/ValidadorDirecciones.java:[12,50] package cl.mein.project.sofbecommons.models does not exist [ERROR] /home/ph1l/Workspace/SOFERTAS/sof-be-direcciones/src/main/java/cl/mein/project/sofbedirecciones/infraestructure/adapters/ValidadorDirecciones.java:[21,17] cannot find symbol [ERROR] symbol: class Direccion [ERROR] location: interface cl.mein.project.sofbedirecciones.infraestructure.adapters.ValidadorDirecciones

The same error for every microservice using the commons dependency on every class from the dependency, I'm out of ideas, help please.

I've tried cleaning the Java Language Server Workspace, cleaning each project and recompiling, adding and removing the @EntityScan({ "cl.mein.project.sofbecommons" }) and replacing it with @EntityScan({ "cl.mein.project.sofbecommons.models" }).

As the project will have at least 6 microservices I need them all to access de commons, to avoid recreating each class on every project, or the strict necesary...

I need to find the error as why it won't find the classes and fix it so i can compile. As i mentioned it works fine on debug (from vscode).

0

There are 0 answers