Avatar ·

IntelliJ IDEA says "Cannot resolve symbol", but code compiles via Maven

Hi everyone. I'm a beginner Java developer using IntelliJ IDEA Ultimate and Maven for building projects. I've encountered a strange issue: the IDE highlights some classes and methods in red, saying "Cannot resolve symbol", but the project builds successfully with `mvn clean install`. \n\nHere's an example. I have a `common` module and a `service` module. In `service`, I import a class from `common`:\n\n```java\npackage com.example.service;\n\nimport com.example.common.dto.UserDto; // IntelliJ underlines in red\nimport com.example.common.util.Validator; // also red\n\npublic class UserService {\n \n public void processUser(UserDto user) {\n Validator.validate(user); // Cannot resolve method 'validate'\n System.out.println("User processed: " + user.getName());\n }\n}\n```