MAVEN environment variable configuration:
Variable name: M2_home variable Value: D:\bin\apache-maven-2.2.1 (Installation path)
Append%m2_home%\bin after path value; (Note to add a semicolon)
Test:
Mvn–version
The MAVEN common commands are:
Mvnarchetype:create: Creating a Maven Project
MVN compile: Compiling source code
Mvntest-compile: Compiling test code
MVN test: Running unit tests in the application
MVN site: Sites that generate project-related information
MVN clean: Clears the build results from the target directory
MVN package: Generate Jar files from project
MVN install: Installing the jar in the local Repository
Mvneclipse:eclipse: Generate Eclipse Project files
Build Project
Build a JAVA project: MVN Archetype:create-dgroupid=com.demo-dartifactid=app
Build a Web project: MVN Archetype:create-dgroupid=com.demo-dartifactid=web-app-darchetypeartifactid=maven-archetype-webapp
Archetype is a built-in plugin that creates a project skeleton for his create task
Archetypeartifactid type of project skeleton, DartifactId project name
The available project skeletons are:
Maven-archetype-archetype
Maven-archetype-j2ee-simple
Maven-archetype-mojo
Maven-archetype-portlet
Maven-archetype-profiles
Maven-archetype-quickstart
Maven-archetype-simple
Maven-archetype-site
Maven-archetype-site-simple, and
Maven-archetype-webapp
------------------------------------------------------------------------------------------
Setting.xml configuration file
Localrepository: Local inventory location, jar package save location, default ${user.dir}/.m2/repository
Offline:true/false, if you do not want to find the Remote center library every time you compile, set to True, if you have downloaded the package
Servers: Configuring a specific user
<servers>
<server>
<id/><username/><password/><privatekey/><pssphrase/>
<filePermissions/><directoryPermissions/><configuration/>
</server>
</servers>
ID: Used to match distributionmanagement library ID
Username,password: User name and password for logging on to this server
Privatekey,passphrase: Set private Key, and passphrase
Filepermissions,directorypermissions: Access Rights 664/775
MIRROSRS: Mirror library for adding additional libraries
<mirrors>
<miror>
<id/><name/><url/><mirroOf/>
</mirror>
</mirrors>
Id,name: The only flag used to distinguish the mirror
URL: The URL of the mirror
MIRROROF: The service ID that this image points to
Proxies: Proxy settings for configuration that cannot directly access the Central Library
<proxies>
<proxy>
<id/><active/><protocol/>
</proxy>
</proxies>
ID: Flag of the agent active: whether to activate the agent
Protocol,host,port:protocol://host:port Agent
Username,password: User name password nonproxyhosts: Host not required for proxy
Repositories and Pluginrepositonries define the local development library for release release
<repositories>
<repository>
<id/><name/><url/>
<releases>
<enabled/><updatePolicy/><checksumPolicy/>
</releases>
<snapshots>
<enabled/>
</snapshots>
<layout/>
</repository>
</repositories>
-----------------------------------------------------------------------------------------------
Pom.xml configuration file
There is also a dependency on defining the jar package version in Pom.xml, managing the jar file.
including configuration files, development of rules to follow, defect management systems, organization and licenses, project dependencies
GROUPID: Project or organization unique flag, and build project path
Artifactid: Project name version: Project Versions
Packaging: A packaging mechanism, such as Jar,pom,war ....
Definition of inheritance in maven
<project>
<modelVersion/><groupId/><version/><packaging/>
</project>
The parent project packaging type needs to be a pom, used for parent and composite multiple projects, and the sub-project is
<parent>
<groupId/><artifctId/><version/>
</parent>
Modules synthesis
<modules>
<module>tc-dient</moduble>
<module>tc-server</module>
</modules>
Build settings: For compilation settings, including two main elements, Build,report
<project>
<project>
<build/>
<profies>
<profile>
<build/>
</profile>
</profies>
</profiles>
</project>
Build-plugin Plug-in
<project>
<build>
.....
<plugins>
<plugin>
<groupId/><artifactId/><version/>
<extensions/><executions/>
</plugin>
</plugins>
</build>
</project>
Extensions:true/false whether to load plug-in extensions, default to False
Inherited:true/false whether this plug-in configuration applies to Poms (inheritance)
Configuration: Specifying plug-in configurations
Dependencies: The package that the plugin needs to rely on
Executions: For configuring execution targets, a plug-in can have multiple targets
Build-resources resources, resources that need to be specified in the project such as: Log4j.properties
<project>
<build>
<resources>
<resource>
<targetPath/><filtering/><directory/>
<includes>
<include/>
</includes>
<excludes>
<exclude/>
</excludes>
</resource>
</resources>
<testResources>
...
</testResources>
....
</build>
</project>
Resources: list, including all resources
TargetPath: Specifies the destination path, which is used to place the resource for the build
Filtering: Whether to replace the attribute in the resource Placehold
Directory: where resources are located
Includes: styles, including resources
Excludes: excluded resources
Testresources: Test Resource List
Dependencies: Dependencies
<dependencies>
<dependency>
<groupId/><artifactId/><version/>
<type/><scope/><optional/>
</dependency>
</dependencies>
Groupid,artifactid,version: Describes a dependent project unique flag
Use the following command to install:
Mvninstall:install-file–dfile=non-maven-proj.jar–dgroupid=some.group–dartifactid=non-maven-proj–dversion=1
Create your own library and configure it, use Deploy:deploy-file to set this dependency to system, and define a systems path. Not advocated.
Type: The corresponding dependent product package form, such as Jar,war
Scope: Used to limit the corresponding range of dependencies, including the following variables:
Compile: Default scope, for compiling
Provided: similar to compile, but support you expect JDK or container to provide, similar to Classpath
Runtime: When executing, you need to use the
Test: Used with the test task
System: You need to provide the appropriate elements externally. Through Systempath to obtain
Systempath: Only for the range of system. Provide the appropriate path
Optional: Annotations are optional when the project itself is also dependent. Used for continuous dependencies
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
MAVEN Configuration Command Introduction