Maven Getting Started Tutorial

Source: Internet
Author: User
Tags solr

Maven Getting Started Tutorial
First, Maven Introduction
MAVEN is a project management tool
It contains:
A Project Objects model (Project object models)
A set of standard collections
A Project life cycle (Project Lifecycle)
A dependency management system (Dependency Management Systems)
Logic used to run the plug-in (plugin) target (goal) defined in the life cycle phase (phase)
Project structure:
The source code is placed in the Src/main/java
Source-code resource files are placed in the Src/main/resources
The test code is put in Src/test/java
The resource file for the test code is placed in the Src/test/resources
As shown in the following:


Pom:
Pom as a Project object model. The MAVEN project is represented by XML and is implemented using Pom.xml.
The main description of the project: including configuration files, the rules that developers need to follow, bug management systems, organization and licenses, project URLs, project dependencies, and all other project-related factors.
Detailed structure:
<parent>
......
<!--the relative path to the Pom.xml file for the parent project. Relative paths allow you to select a different path.
The default value is: /pom.xml.
Maven first looks for the Pom of the parent project where the current project is built,
Next in this location of the filesystem (RelativePath location), then in the local repository, finally in the remote warehouse looking for the parent project of the Pom. -
<relativePath/>
</parent>
<!--the types of artifacts generated by the project, such as jar, war, ear, Pom. Plug-ins can create their own artifact types, so the preceding columns are not all component types--
<packaging>jar</packaging>
The <!--SCM (source Control Management) tab allows you to configure your code base for use by Maven Web sites and other plugins. -
<scm>
<!--the URL of the SCM, which describes the repository and how to connect to the repository. For more information, see the URL format and list provided by SCMS. The connection is read-only. -
<connection>
Scm:svn:http://svn.baidu.com/banseon/maven/banseon/banseon-maven2-trunk (Dao-trunk)
</connection>
<!--to developers, similar to connection elements. That the connection is not just read--
<developerConnection>
Scm:svn:http://svn.baidu.com/banseon/maven/banseon/dao-trunk
</developerConnection>
<!--the label of the current code, which is head--> by default in the development phase
<tag/>
<!--a URL that points to the project's Browsable SCM Library (for example, VIEWVC or fisheye). -
<url>http://svn.baidu.com/banseon</url>
</scm>
<resources>
<!--This element describes all resource paths related to a project or test-
<resource>
<!--whether to use parameter values instead of argument names. The parameter values are taken from the properties element or the attributes configured in the file, and the files are listed in the filters element. -
<filtering/>
<!--describes the directory where the resource is stored, which is relative to the POM path-
<directory/>
<!--the list of patterns included, such as **/*.xml.-->
<includes/>
<!--excluded List of patterns, such as **/*.xml-->
<excludes/>
</resource>
</resources>
<!--a list of filter properties files to use when the filtering switch is turned on--
<filters>
<filter>src/main/resources/filters/db/jdbc-${env}.properties</filter>
<filter>src/main/resources/filters/redis/redis-${env}.properties</filter>
<filter>src/main/resources/filters/rocketmq/rocketmq-${env}.properties</filter>
<filter>src/main/resources/filters/solr/solr-${env}.properties</filter>
<filter>src/main/resources/filters/zookeeper/zookeeper-${env}.properties</filter>
</filters>
<!--project distribution information that represents the location to publish after MVN deploy is executed. With this information, you can deploy the Web site to a remote server or deploy the artifacts to a remote repository. -
<distributionManagement>
<!--the artifacts generated from the deployment project to the remote warehouse need information--
<repository>
<!--is a unique version number (by timestamp and build serial number) assigned to the snapshot? Or do you use the same version number every time? See Repositories/repository elements--
<uniqueVersion/>
<id>banseon-maven2</id>
<name>banseon maven2</name>
<url>file://${basedir}/target/deploy</url>
</repository>
Where are snapshots of <!--artifacts deployed? If the element is not configured, it is deployed by default to the warehouse of the repository element configuration, see distributionmanagement/repository element--
<snapshotRepository>
<uniqueVersion/>
<id>banseon-maven2</id>
<name>banseon-maven2 Snapshot repository</name>
<url>scp://svn.baidu.com/banseon:/usr/local/maven-snapshot</url>
</snapshotRepository>
<!--the site of the deployment project needs information--
<site>
<!--a unique identifier for the deployment location to match the configuration in the site and the settings.xml file.
<id>banseon-site</id>
<!--deployment Location name--
<name>business API Website</name>
<!--the URL of the deployment location, by Protocol://hostname/path
<url>
Scp://svn.baidu.com/banseon:/var/www/localhost/banseon-web
</url>
</site>
</distributionManagement>
Project coordinates:
GAV--&GT;GROUPID (Project ID, typically package name), Artifacid (project name or module name), version (Project version). Maven discovers projects and generates dependencies through project coordinates.
Second, MAVEN installation
2.1. Download:
: http://maven.apache.org/download.cgi#Installation
2.2, decompression, configuration environment variables
2.3. Verify the command-line window-->mvn-version. Appears as follows to prove the installation was successful.


Third, MAVEN Warehouse
Central Warehouse
Configured in the Org.apache.maven.model.pom4.0.0.xml,maven package, you can modify the remote warehouse address
Private Warehouse
It is usually a private server built within the company's local area network to store the jar files required by the company.
Build steps:
Install Nexus, unzip
Configuring Environment variables
Perform nexus install, publish Nexus as Windows Service, control Panel can see
Modify the installation directory/bin/jsw/conf under Wrapper.conf, and modify the following command path for the set the JVM executable to the JDK installation directory \bin\java
Start the service with Nexus start
Input via browser after starting service: Localhost:8080/nexus Access Nexus
Warehouse explanation
hosted--release warehouse for internal projects
3rd Part Warehouse---Third-party Package publishing warehouse, which is usually published by internal personnel after download
Release---released warehouse for the release module in the internal module
Snashot---Publishing the internal snapshot module warehouse
Proxy---A warehouse looking for data from a remote central warehouse
Mirror Mirroring
Private Warehouse Settings
1, update the private warehouse index or download the index, copy it to the Central warehouse in the index directory
2. Set the image
3. Configure the Warehouse
Local Warehouse
PC or developer PC, can specify the directory of jar files by setting Setting.xml
Items from the local server to find, local can not find to go to the private server to find, the private server can not find the central warehouse to find.

Maven Getting Started Tutorial

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.