Maven automatically manages the Jar package - Eclipse will preferentially associate with the same project instead of the specified jar package

As we all know, starting from Maven2, Maven can automatically manage the development packages (Jar packages) referenced by Java applications, which is officially called transitive dependency (transitive dependency management), which means that Java applications only need to define their direct references. Jar package dependencies without having to define all the Jar dependencies referenced by the Java application. Maven 2 can automatically add other Jar packages that Java applications directly reference libraries depend on.

 

But today when developing the project, I encountered a weird Exception when executing the Unit Test or Main method in Eclipse: Porject XXX is missing required Java project YYY. As shown below.



 

This makes me feel very strange, because I imported a jar package called cms-java-typesafe-api in the tools-cms-client project, instead of importing this project, as defined in the following pom:



 

Later I remembered that I had a project named cms-java-typesafe-api in the same workspace (the project and cms-java-typesafe-api.jar have the same three-dimensional: groupId, artifactId, version), in Eclipse If you do not close the project, eclipse will display the classes imported into the project instead of the classes in cms-java-typesafe-api.jar. Then the obvious thing to do is to close the cms-java-typesafe-api project. But although the project is closed, when it runs in Eclipse, it will give priority to referencing the classes in the project, and at this time the project is closed again, so the above Exception appears in Eclipse: Porject XXX is missing required Java project YYY

 

 

The best solution is to change to another workspace, do not introduce a jar package named cms-java-typesafe-api.jar into another project in the workspace with this project: cms-java-typesafe-api .

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326944270&siteId=291194637