Some Notes on Maven

Maven


  • Introduction to Maven
  • Maven installation configuration
  • Basic use of Maven
  • IDEA deployment Maven
  • dependency management

Introduction to Maven

  • Maven is a tool specially used to manage and build Java projects. Its main functions are:

    • Provides a standardized project structure
    • Provides a standardized build process (compile, test, package, release...)
    • provides a set of dependencies
  • Apache Maven is a project management and construction tool. It is based on the concept of the project object model (POM [Project Object Module]), and manages the construction, reporting and documentation of the project through a small piece of description information.

maven

  • Warehouse classification:
    • Local warehouse: a directory on your own computer
    • Central warehouse: the only warehouse in the world maintained by the Maven team
    • Remote warehouse (private server): generally a private warehouse built by a company team

Basic use of Maven

  • Maven Common Commands

    • compile: compile
    • clean: clean up
    • test: test
    • package: package
    • install: install
  • Maven life cycle (Maven divides the life cycle of project construction into 3 sets)

    • clean: cleaning work
    • default: core work, such as compilation, testing, packaging, installation, etc.
    • site: Generate reports, publish sites, etc.

    In the same life cycle, execute the following commands, and all previous commands will be executed automatically

  • Detailed explanation of Maven coordinates

    What are coordinates?

    • Coordinates in Maven are unique identifiers for resources
    • Use coordinates to define the project or introduce dependencies needed in the project

    The main components of Maven coordinates

    • groupId: Define the name of the organization to which the current Mavenue project belongs (usually the domain name is reversed, for example: com.spernxl)
    • arrtifactId: defines the current Maven project name (usually the module name, such as order-service, goods-service)
    • version: defines the current project version number
    <groupId>com.spernxl</groupId>
    <artifactId>maven-demo</artifactId>
    <version>1.0-SNAPSHOT</version>
    
  • Dependency scope

    • By setting the dependent scope of the coordinates (scope), you can set the scope of the corresponding jar package: compilation environment, test environment, running environment

      <dependency>
          <groupId>com.spernxl</groupId>
          <artifactId>maven-demo</artifactId>
          <version>1.0-SNAPSHOT</version>
          <scope>test</scope>
      </dependency>
      
      Dependency scope compile classpath test classpath run classpath example
      compile Y Y Y logback
      test - Y - Junit
      provided Y Y - servlet-api
      runtiome - Y Y jdbc driver
      system Y Y - jar package stored locally

      |
      | system | Y | Y | - | jar package stored locally|

      Default: compile

Guess you like

Origin blog.csdn.net/qq_48778364/article/details/127775241