java-eclipse-Creating a Maven project

Source: Internet
Author: User

1. Create a project

1.1. New in Eclipse – select Maven Project


1.2. Select Create a simple project

1.3. Click Next to enter the next
Group Id,artifact ID, you can write a random, select the war type in packaging
Note: GroupID plus Artifactid requires globally unique
General GroupID are package names
Artifactid for Project name
Maven can manage the jar packages that the project relies on, with GroupID, Artifactid, and version numbers to uniquely identify a jar package. This prevents the web-inf/lib of the jar package from being inconsistent under the old Web project. Maven also automatically downloads the jar packages that are added to the jar package.

1.4. Click Next and continue next in the following steps until the last click Finish

2. Configuration Items

2.1.maven jar Dependency
Right-click the project, select Properites, and open the following dialog box

2.2.web Configuration
Page opened in previous step-check Project facets– Select Custom in Configuration
Select version 2.5 in the dynamic WEB module of the project facet below
Select 1.6 in Java
Note: These choices may vary depending on the version of Tomcat, and it is possible for TOMCAT6 to select the options above.
This step is very important, only the right navigation bar will have the deployment Assembly link only if you have done this step


Next click on the runtime panel on the right panel
, select Tomcat if not to see Tomcat below, if not, then click New, create a new one, select the check box after new, and then Apply,ok

3. Related instructions

Src/main/java
This folder is stored in Java source code, publish the project will be under the folder of the class file copied to the Web-inf/classes directory

Src/main/resources
This folder generally placed configuration files, such as xml,properties files, etc., can also be placed in Java files, just a convention, when the project was published
Files for this folder are also copied to Web-inf/class
As for test, there are some similarities, but these are testing code, and using Maven should know that.

Src/main/webapp
The contract in Maven is to think of the folder as a Webroot directory in a normal Web project, see the Deploy path on the right, and publish the project
is published to the root directory/. The folder is in the built Maven WEB project, and there are no Web-inf/classes,web-inf/lib folders in it
Need to be built manually

In fact, this is also possible to run the project, debugging the project, however, if you run the project's Pom.xml file will be an error, why,
Because Maven treats the Src/main/webapp file as a webroot in a normal Web project, the inside of your configuration ()
Without configuration, it will be an error.
What to do, 2 steps.
1. Select Webcontent,remove to drop it
2, create a new, the source folder for Src/main/webapp,deploy path is/
Click Apply,ok.

Finally, the MAVEN library must be mapped to Web-inf/lib, as follows, click the Add button to enter

Select Java Build Path entries, click Next, enter

Select Maven Dependencies and click Finish to end up as

java-eclipse-Creating a Maven project

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.