Summary: Helped colleagues to solve the problem that they could not find classes and maven reported red in the Build phase when Git pulled new projects.

The cause of the problem

Unable to find the corresponding JAR from the coordinates in the POM file or in a JAR version update resulting in the required class not being present and not being able to import in Java code.

  • If a JAR from maven’s public repository cannot be imported, you can modify the coordinate parameters of the POM file<version>Update the version value in.
  • When the jar package pulled from the Nexus private server does not match the required version of the current code, there may be problems with importing the required classes.

If in version 1.0, project 1 uses the class A of Project 2 in private server, and in version 2.0, the name of project 2’s class A is changed to B due to business changes, the required classes cannot be correctly introduced in Project 1.

The solution

  1. If the developers of Project 2 update the code and upload the dependencies to the private server in time, we can update Maven.
  2. If the developer of Project 2 does not upload the private server in time after modifying the code, we can use IDEA to locate the file path where the Jar is located, package the correct version of the code and place it in the local Maven repository. After the replication, remember to select the Toggle Offline Mode of IDEA, which means that only the local JAR is refreshed and the private server is not pulled. Otherwise, this Mode will pull the jar package of the old version in the private server, which cannot solve the problem.
  3. Solution 2 is the obvious solution to the oddness, and the final solution is to contact the JAR provider to update the latest version of the JAR package to the private server.