MAVEN3 Study Notes

Source: Internet
Author: User

1. Install Maven

Maven Project official website: http://maven.apache.com

1.1. Download the version that meets the requirements:

2013-10-04 3.1.1 Java 5
2014-12-20 3.2.5 Java 6
2015-11-14 3.3.9 Java 7 (currently up-to-date)

1.2. Install JDK, configure Java_home variable

Test: Java--version

1.3. Configure the path of MAVEN in path

Test: MVN--version

2. Configure maven2.1. Local Warehouse

Default path: C:\User\UserName\.m2\repository
Modification Method:

User Directory settings: C:\User\UserName\.m2

System directory settings:./apache-maven-3.*/conf/settings.xml <localRepository>Path</localRepository>

2.2. Remote Storage

Default path: Global Unified Address
Using mirroring:

<mirror>
<id>Central</id>
<mirrorOf>central</mirrorOf>
<name>repo1</name>
<url>http://repo1.maven.org/maven2</url>
</mirror>
<mirror>
<id>nexus-osc</id>
<mirrorOf>*</mirrorOf>
<name>nexus osc</name>
<url>http://maven.oschina.net/content/groups/public/</url>
</mirror>

3. Directory structure using Maven3.1.maven conventions

Src
-main
-java
-(package)
-test
-java
-(package)
-resources

3.2.maven life cycle

Clean Cleanup Project
Pre-clean perform pre-cleanup work
Clean cleans up all files generated by the previous build
Post-clean performing cleanup work/files
Default Build Project
Compile Test Package Install
Site Build Project Sites
Pre-site What to do before you build the project site
Site-generated Project Web document
Post-site the work to be done after building the project site
Site-deploy publishing the generated site to the server

3.3.MVN command

-V View Maven version
-compile compiling
-test Test
-package Packaging

Clean Delete target
Install the jar package to the local repository

There are two ways to create a directory:
1.archetype:generate follow the prompts to select
2.archetype:generate-dgroupid= organization name, anti-write of company URL + project name
-dartifactid= Project Name-module name
-dversion= Version number
The package name that is present in the-dpackage= code

3.4. Version number

0.0.1
The first 0 indicates a large version number
The second 0 indicates a branch version number
The third 0 represents the minor version number

3.5. Configure Pom.xml
<?XML version= "1.0" encoding= "UTF-8"?><Projectxmlns= "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>Com.test.demo</groupId> <Artifactid>Test</Artifactid> <version>1.0.0</version> <Packaging>Jar</Packaging> <name>Test</name> <Dependencies> <Dependency> <groupId>Log4j</groupId> <Artifactid>Log4j</Artifactid> <version>1.2.8</version> </Dependency> </Dependencies> <Build> <Resources> <Resource> <Directory>Src/main/resources</Directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>False</filtering> </Resource> <Resource> <Directory>Src/main/java</Directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>False</filtering> </Resource> </Resources> <Plugins> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-compiler-plugin</Artifactid> <version>2.3.1</version> <Configuration> <Source>1.6</Source> <Target>1.6</Target> <encoding>Utf8</encoding> </Configuration> </plugin> </Plugins> </Build> </Project>

MAVEN3 Study Notes

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.