How to create a MAVEN project that supports the Eclipse IDE

Source: Internet
Author: User

Projects created with Maven are not supported by any IDE and cannot be imported into the IDE because the project format does not conform to the specific IDE's formatting requirements, so how do I create a project that meets the requirements of the IDE?

1. Use the MVN eclipse:eclipse command to convert the project into a project that supports the Eclipse IDE.

2. Use the MVN Idea:idea command to convert the project into a project that supports IntelliJ idea.

The following only shows how to convert a MAVEN project to a project supported by the Eclipse IDE.

1, enter the project root directory, that is, the project's Pom.xml directory, and then execute the command mvn eclipse:eclipse, then maven will automatically generate eclipse The. Classpath and. project files required by the IDE so that the project can be imported into the Eclipse IDE: the classpath content is as follows.

1 <Classpath>2   <ClasspathentryKind= "src"Path= "Src/test/java" 3 Output= "Target/test-classes"including= "**/*.java"/>4   <ClasspathentryKind= "src"Path= "Src/main/java"including= "**/*.java"/>5   <ClasspathentryKind= "Output"Path= "Target/classes"/>6   <ClasspathentryKind= "var"Path= "M2_repo/junit/junit/3.8.1/junit-3.8.1.jar" 7 SourcePath= "M2_repo/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>8   <ClasspathentryKind= "Con"Path= "Org.eclipse.jdt.launching.JRE_CONTAINER"/>9 </Classpath>

We can see that there is a M2_repo class path variable, which represents the location of the local repository, if you are using the command for the first time, you need to configure the variable in the Eclipse IDE, or eclipse will error after importing the project.

The purpose of configuring this M2_repo variable is to let eclipse know where to find the local repository, and there are two ways to configure it:

Method 1: Manually configure the menu bar at the top in order to do the following: Window > Preferences > Java > Build Path > Classpath Variables, click the New button to define a new m2_ Repo the variable and point it to Maven's local repository so that it will be shared by all eclipse projects later.

Method 2: Automatic configuration, using the following MAVEN command autoconfiguration: mvn-declipse.workspace= "Your Eclipse workspace" Eclipse:configure-workspace, Change the Eclipse workspace to your own, and then follow the steps in Method 1 to see if the join was successful.

2. Import the project into the IDE

Now, with the IDE's Import Project Wizard, it's easy to import our MAVEN-generated projects into the IDE, which you can then develop in the IDE.

How to create a MAVEN project that supports the Eclipse IDE

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.