MAVEN Create WebApp

Source: Internet
Author: User

Maven is a more popular Jar package management tool in recent years.
Many open source projects or demo code are MAVEN-based projects.
Pros and cons Javeeye has had a very heated discussion. Don't make too many comments here.
But according to my experience.
After using MAVEN, I don't want to go back to the days when I manually added the jar package to Lib.


There are many tutorials and instructions on MAVEN on the web. Don't do too much of it here.

Download Maven3 first.
Maven

Set the system variables for MAVEN after decompression.
such as. Set the system variables for m2_home and path. Input

Java code
    1. Mvn-version


the appearance shown in the figure shows that the installation was successful.



then install the M2eclipse plugin.
can only be installed online.

m2eclipse Core Update site:Http://m2eclipse.sonatype.org/sites/m2e

Note: MyEclipse and STS have their own m2eclipse plug-in, so there is no need to install. Eclipse for Java EE needs to be downloaded separately.
STS with SpringSource is highly recommended (an IDE based on Eclipse integration)
Sts

after installing the M2clipse plug-in.
on the IDE menu bar, click Window --preferences
input maven appears as shown in.



Click on user settings to select the Settings.xml in the Conf folder after you unzip and click Apply.
then click Installations-->add--Select the MAVEN installation directory-->apply



this is where Maven and M2eclipse are built.
We then started to create a standard MAVEN-based Web project framework.


Right-click on the left project area----------find Maven (or directly enter Maven)
-- Select Maven Project

as



Click Next

There will be a lot of archetype. All are maven templates that correspond to different needs.
we chooseMaven-archetype-webapp
a Web-based template.




Click Next
input
GroupID and Artifactid

GroupID Just fill it out, but it's best to fill in the name of the company or organization.
Artifactid can think of him as a project name, so you fill in the name of the project.





once created, we will get the project structure as shown





but this is not the standard structure of the default MAVEN project. We need to make some changes.

1. Create a source folder under the project.
folder Name:src/main/java
as shown




(Of course, you can also add Src/test/java and src/test/resources for JUnit tests. )
However, it is not added here.)


2. Create a folder called resources under the WebApp root directory.
used to install static files such as Js,css later.

3. Delete index.jsp

4. Create 3 packages in Src/main/java (MAVEN standard recommendation is 3 layer package structure)

5. If the JDK installed is 1.6, change the JRE system libary to the 1.6 version.

so. A standard MAVEN Web project was created successfully.




How do I start a project?

Many people are asking how to start a project after the project is created? How do I start the server?

It's actually very simple.
Mail Click Tomcat



such as. Click Add or Remove .




Add the item you want to start to the right. After the point is determined, the project is deployed to Tomcat.

There is also an easier way.
drag the project directly onto Tomcat









start on OK.

If you can't put your project into Tomcat, check to see if your MAVEN project is a Web project.

The Maven project is actually useful mvn pulgin to start the project.
such as Maven-jetty or Maven-tomcat.
These are Maven's knowledge points, and do not make too much of it here.

Interested friends can find the relevant knowledge on their own.

Reprint Address: http://tomfish88.iteye.com/blog/1142403

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.