JavaEE Senior -Maven study notes

About Maven

  1, Maven is a Java platform serving the automated build tool.

  2, build:

    - concept: the "Java Source File", "Framework configuration file", "JSP", "HTML", "Pictures" and other resources for the "raw material", to "produce" a project can run the process

    - Compile: Java source files User.java [] -> compile -> Class bytecode files [User.class] -> go to the JVM execution

    - Deployment: a BS project is not final run dynamic Web project itself, but "to compile the results," this dynamic Web project

  3, all aspects of the build process

    - Clean: will remove the old class bytecode files compiled previously obtained, compiled in preparation for the next time

    - Compile: the Java source code is compiled into bytecode class file

    - Testing: automatic test, automatic call junit program

    - Report: results of the test program execution

    - Packaging: Dynamic Web project to fight the war package, Java jar packaging engineering

    - Installation: Copy Maven particular concept, will pack the resulting file to a specified location "warehouse" in the

    - Deployment: Copy dynamic Web project generated war package to a specified directory Servlet container, you can run

  4, building automation

 

Installing Maven core program

  1. Check the JAVA_HOME environment variable

  2, core decompression procedure Maven compressed, in a non-free space path Chinese

  3, configure Maven related environment variables

    M2_HOME

    path

  4, run mvn -v command to see the version of Maven

 

Maven's core concepts

  1, the directory structure of the agreement

  2、POM

  3, the coordinates

  4, dependence

  5, warehouse

  6, Life Cycle / plugin / goal

  7, inheritance

  8, the polymerization

 

The first Maven project

  1, create a directory structure convention

    Root: project name

    src directory: source

    pom.xml file: Maven project's core profile

    main directory: storing the main program

    test directory: store test program

    java catalog: store Java source files

    resources directory: storage frame or profiles of other tools

 

Common Maven command

  Note: Execute the command associated with the Maven build process, you must enter the directory where the pom.xml

  Commonly used commands:

    mvn clean: clean up

    mvn compile: Compile the main program

    mvn test-compile: compile the test program

    mvn test: a test is performed

    mvn package: Package

    mvn install: install

    mvn site: site generation

 

POM

  1, meaning: Project Object Model Project Object Model

  2, pom.xml for Maven project is the core configuration file, all settings associated with the build process are configured in this file

 

coordinate

  1, the mathematical coordinates

  2, Maven coordinates

    Use the following three vector unique positioning a Maven project in the repository

    groupid: the company or organization domain name flashbacks + project

    artifactid: module name

    version: Version

 

warehouse

  1, classification warehouse

    Local Warehouse:

    Remote repository:

      - PW: set up under the current LAN environment, for all Maven projects within the scope of the current local area network services

      - Central Warehouse: erected on the Internet, for all the world Maven Engineering Services

      - Central warehouse Mirror: share the traffic central warehouse, enhance user access speed

  2, stored in the warehouse contents: Maven project

    - Maven itself require plug-ins

    - jar package third-party frameworks or tools

    - Maven project development of our own

 

rely

  1, Maven will find local repository is dependent jar package when parsing dependency information

    - Maven project for our own development, the use mvn install command after installation can enter the warehouse

  2, the range-dependent

    - compile range depends: are valid for the main program, test the program, participation package

    - test range depends: on the main program is invalid, valid for the testing procedures involved in packaging

    - provided range dependence: valid for the main program, the test program, not involved in packaging, is not involved in the deployment

 

The life cycle

  1, the order of execution of the various aspects of building: only in that order, must be performed in accordance with established correct order

  2, Maven's core program defines the abstract of the life cycle, the life cycle of specific tasks for each phase is to be completed by the plug

  3, Maven core program in order to better automate the build, execute the various stages of the life cycle of the following characteristics:

    That is, no matter which one of a stage of the life cycle, all started from the initial position of the life cycle

  4, plug-ins and goal

    - the various stages of the life cycle of only defines what tasks are to be performed

    - target all stages and plug-ins is the corresponding

    - similar goals to complete by a specific plug-ins

 

Using Maven in Eclipse

  1, Maven plug-ins: Eclipse built

  2, set the Maven plugin

    - installations: specify the location of Maven core program.

    - user settings: Specifies the conf / settings.xml location, location then obtain a local warehouse

 

Guess you like

Origin www.cnblogs.com/LzMingYueShanPao/p/11206619.html