Maven creates Java and Web Project and imports Eclipse__java

Source: Internet
Author: User


Java Projects


Create a Javastudy project with the following steps:
1. Switch to directory on command line
CD D:\devworkspace\ecpoxyworkspace


2. Execute Create command
MVN archetype:generate-dgroupid=com.oscar999-dartifactid=javastudy-darchetypeartifactid= Maven-archetype-quickstart-dinteractivemode=false
This step will take a long time.
The completed directory structure is created as follows:




Generates Pom.xml and code directories, and tests directories. and have the test code App.java


3. Import Eclipse
To the Engineering directory CD D:\devworkspace\ecpoxyworkspace\JavaStudy
Perform MVN eclipse:eclipse
After you execute the above command, it automatically downloads updates related resources and configuration information (it will take some time to wait) and produces all the project files required by the Eclipse IDE.
When the execution is complete, the. classpath and. Project two files are created.
To import the project into the Eclipse IDE, select "File-> Import ...-> general->existing Projects into Workspace"


If you do not perform this step, you cannot import it in project mode.


Web Project
1.  MVN Archetype:generate-dgroupid=com.oscar999-dartifactid=webstudy- Darchetypeartifactid=maven-archetype-webapp-dinteractivemode=false
Generate project Structure




2. Import Eclipse The
mvn eclipse:eclipse-dwtpversion=2.0
-dwtpversion=2.0 tells Maven to convert the project to Eclipse's Web project (WAR) instead of the default Java project (JAR).


 eclipse ide–file-> Import ...-> general-> Existing Projects to workspace


Note: If you add the following section to the Pom.xml

<!--Eclipse Project-->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-eclipse-plugin</artifactId>
  <version>2.9</version>
  < Configuration>
    <!--Always download and attach dependencies source code-->
    <downloadSources> true</downloadsources>
    <downloadJavadocs>false</downloadJavadocs>
    <!--avoid type MVN eclipse:eclipse-dwtpversion=2.0-->
    <wtpversion>2.0</wtpversion>
  </configuration >
</plugin>




You can ignore the above-dwtpversion=2.0 parameters.
That is, MVN eclipse:eclipse,maven the import of this project into the Eclipse Web project




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.