Eclipse turns Java Web project into MAVEN project __web

Source: Internet
Author: User
Tags java web log4j

Develop a project of your own, build Dynamic Web project, the result of submitting code to the operational personnel when they request to use the MAVEN project, said this better management. It's a shame I used to have too little maven, so learn.

1. Convert Project type

Right-click item and see the Configure option, direct convert to Maven project, the entire project directory will change, as shown

With more MAVEN's iconic file Pom.xml, the edit box pops up as follows

OK, the MAVEN project has been converted, here you can edit your version, artifact ID and other information.

2. Editor Pom.xml

Click on the pom.xml below to enter the POM edit mode.

In a normal project we just need to add some dependencies, and we can go to http://www.mvnrepository.com/to find the dependent packages.

From the project's referenced libraries subdirectory can see their own dependencies, such as my project needs Mahout package, then I go to the site search mahout, according to their own needs of the package and version, into the following page.

You can see the dependency of an XML markup language and copy this into your pom.xml. Here is my pom.xml section of code.

<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <groupId>SmartPush</groupId> <artifactid>smartpush </artifactId> <packaging>war</packaging> <dependencies> <dependency> <groupid&gt ;org.apache.mahout</groupid> <artifactId>mahout-core</artifactId> <version>0.9</ version> </dependency> <dependency> <groupId>org.apache.mahout</groupId> <artifact id>mahout-math</artifactid> <version>0.9</version> </dependency> <dependency> & Lt;groupid>mysql</groupid> <artifactId>mysql-connector-java</artifactId> <version> 5.1.30</version> </dependency> <dependency> <groupid>log4j</groupid> <artifactId>log4j</artifactId> <version>1.2.17</version> &L t;/dependency> </dependencies> <build> <sourceDirectory>src</sourceDirectory> <reso urces> <resource> <directory>src</directory> <excludes> <exclude>**/*.jav
				a</exclude> </excludes> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration&
					Gt <source>1.7</source> <target>1.7</target> </configuration> </plugin> &L t;plugin> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <conf Iguration> <warSourceDirectory>WebContent</warSourceDirectory> &LT;FAILONMISSINGWEBXML&GT;FALSE&L T;/failonmissingwebxml> </configuration> </plugin> </plugins> </build> <version>0.0.1</versio N> </project>

3. Compile

Go to your own project directory and execute the following command

$MVN Compile

$MVN Package
You can see the required war file in the target directory.

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.