Eclipse avoids dependency-referenced scenarios between modules in a multi-modules project structure

Source: Internet
Author: User

This is not a problem when it comes to a single classloader. If there is more classloader, there will be a problem.

Assuming that the project has two modules, Module2 relies on Module1

After we perform the MVC eclipse:eclipse and then look at the. classpath file under Module2, you will find: <classpathentry kind= "src" path= "/module1"/>.

If Module1 is pom.xml, we declare a third-party dependency (assuming Servlet-api) scope:provided. You will find that the BuildPath in Module2 will still have this third-party dependency (SERVLET-API). Even if you are in the Module2 Pom.xml in Module1 to exclude servlet-api actual or transitive existence.

Typically with a single appclassloader scenario, you may not need to focus on this issue. But if you rely on these classpath to classloader problems, there will be problems.

Workaround:

Declare maven-eclipse-plugin in the Project Master Pom and configure the following to block references to this module.

Specific instructions are as follows: https://maven.apache.org/plugins/maven-eclipse-plugin/examples/prevent-module-references.html

After you re-execute MVN eclipse:eclipse, review the module2. classpath file, <classpathentry kind= "var" path= "M2_repo/com/xxxx.../{version }/module1-{version}.jar ". Check the BuildPath at this time and clean.

Note: This problem is not present in Intellj idea.

Eclipse avoids dependency-referenced scenarios between modules in a multi-modules project structure

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.