Maven--apache Maven and Lin June Lin's "Jiangnan" __maven

Source: Internet
Author: User

Reprint please indicate the source: http://blog.csdn.net/dongdong9223/article/details/80089678
This article comes from "I'm a Fish's blog" 1 maven and "Jiangnan "

The experience of being in contact with Maven reminded me of the first time I heard about the album "Jiangnan".

Buy "Jiangnan" This album is not like the "Peninsula Iron Box" to sing as poetic, is an encounter, in the video store inadvertently saw JJ Lin out of the second album. Before the "is I" feeling very good, when just understand this new singer soon, so want to listen to see again.

After listening to the "Jiangnan" in all the songs, the first feeling is to buy failed, completely without feeling, put her on the shelf do not want to listen ... After one months, inadvertently turned to want to change the brain, it is surprised so beautiful song. And all the songs in the album are good, before how to listen to ...

This is how it was when I first contacted Maven. Accustomed to the Web project to the theme of the structure routines, is not accustomed to the directory structure of MAVEN, and the other jar package address is not easy to find, with the difficulty. After a while, accidentally try again, try again, try again ... After that, the feeling is inseparable from it, maven management of the jar package structure is too elegant ...

The best way to get to know Maven is, of course, the MAVEN website. Now the technical framework of the official website like to do a 5 minutes or 10 minutes of small tutorials, so that people can quickly start, glimpse and see General, and also enhance the user's self-confidence. MAVEN also set up a Maven in 5 Minutes, and chat with everyone today. 2 Installation

MAVEN installation is very simple, download a file and unzip, configure the environment variables can be, after the successful installation can be entered at the command line:

Mvn-v

To view the MAVEN version, as shown in the figure:

3 Create a project

Maven gives an example of creating a simple project with command line input:

MVN archetype:generate-dgroupid=com.mycompany.app-dartifactid=my-app-darchetypeartifactid= Maven-archetype-quickstart-dinteractivemode=false

Some of the more important parameters:

groundid: coordinates, describing organizational information

Artifactid: coordinates, describing project information

Archetypeartifactid: The template toolkit for MAVEN projects.

Groundid and Artifactid are the coordinates of the MAVEN project, which collectively constitute the uniqueness of the MAVEN project, while Archetypeartifactid is the template toolkit for the MAVEN project, and Maven has many patterns of engineering templates, Can be used to create a project. Here is a simple example template "Maven-archetype-quickstart", which typically creates a Web project using the Web Engineering template "Maven-archetype-webapp".

An engineering folder is created in the current directory, and the file structure is as shown in the picture:

As for what these structures are for, the MAVEN website specializes in a place standard project structure describes what these folders in the MAVEN build project are 4 pom.xml files

The Pom.xml file is the core of MAVEN, and the definition of the jar type and version is in it. The newly produced project Pom.xml documents are as follows:

<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/maven-v4_0_0.xsd" >
  < modelversion>4.0.0</modelversion>
  <groupId>com.mycompany.app</groupId>
  < artifactid>my-app</artifactid>
  <packaging>jar</packaging>
  <version>1.0- snapshot</version>
  <name>my-app</name>
  <url>http://maven.apache.org</url >
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      < artifactid>junit</artifactid>
      <version>3.8.1</version>
      <scope>test</ scope>
    </dependency>
  </dependencies>
</project>

In order to find the path to the jar package is generally to mvnrepository search for a version of the jar package, and then copy it, as shown in the figure:

5 Build Project

Before running the project, first construct the project, enter the engineering directory, and run the command:

MVN Package

After running the command, run for a while and finally enter the following:

This process creates the target directory under the engineering directory, and the created directory file structure contains the folder:

Src
Target
Pom.xml

As shown in the figure:

The file structure in the target folder is shown in the following illustration:

Can see that the project has been compiled and generated a class file that can be run. 6 Operation Engineering

To execute a command:

JAVA-CP Target/my-app-1.0-snapshot.jar com.mycompany.app.App

The result is as shown in the figure:

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.