Maven learning section 1

1. Surfire: Divinity, it will definitely succeed!

             The surefire plugin is used to execute unit tests of an application during the test phase of the maven build lifecycle. It produces two different forms of test result reports:

            1). Plain text
            2) .xml file format

                    By default, these files are generated in the project's ${basedir}/target/surefire-reports directory (basedir refers to the directory where the pom file is located). It can run any unit tests written by testNG, Junit, pojo.

 Second, how to create a Maven project?

        ALT+F5 can know the reason for the error

    

                

              groupid and artifactId are collectively referred to as "coordinates" and are proposed to ensure the uniqueness of the project.
              If you want to get your project to the maven local repository, you must search according to these two ids if you want to find your project.
  The groupId is generally divided into multiple segments, here I only mention two segments, the first segment is the domain, and the second segment is the company name. Domains are divided into org, com, cn, etc., among which org is a non-profit organization and com is a commercial organization. Take the tomcat project of apache company as an example: the groupId of this project is org.apache, its domain is org (because tomcat is a non-profit project), the company name is apache, and the artigactId is tomcat.
        For example, when I create a project, I usually set the groupId to cn.pq, cn means the domain is China, pq is my personal initials, and artifactId is set to FirstTestSpring3, which means that the name of your project is FirstTestSpring3 . According to this setting, your The package structure should preferably start with cn.pq.FirstTestSpring3 j. If there is a StudentPeng, its full path is  cn.pq.FirstTestSpring3.StudentPeng

3. Maven's life cycle?

   

A project has gone through the process of compiling, testing, packaging, publishing and other life cycle, which is called project construction.

There are three separate life cycles in Maven:

  • Clean Lifecycle: Do some cleanup before the real build
  • Default Lifecycle: The core part of the build, compile, test, package, deploy
  • Site Lifecycle: Generate project reports, generate sites, publish sites

    The first and the third are relatively simple and easy to understand. Let’s take a look at the most important Default life cycle of Maven. Most of the work occurs in this life cycle. In this stage, the more important and commonly used stages are:

    • validate
    • generate-sources
    • process-sources
    • generate-resources
    • process-resources: Copy and process resource files to the target directory, ready to package
    • compile: compile the project source code
    • process-clases
    • generate-test-sources
    • procss-test-sources
    • generate-test-resources
    • process-test-resources: Copy and process resource files to the target test directory
    • test-compile: compile the test source code
    • process-test-classes
    • test: Test runs using a suitable unit testing framework, these test code will not be packaged or deployed
    • prepare-package
    • package: Accept compiled code and package it into a releasable format, such as jar
    • pre-integration-test
    • integration-test
    • post-integration-test
    • verify
    • install: install the package to the local repository so that other projects can depend on it
    • deploy: Copy the final package to a remote repository for other developers to share with the project

    Basically, just by the name we can guess what each stage is for. Remember that at any stage, all stages before it will be run , which is why when we run mvn clean install, the code will be compiled, tested, and packaged.

    In addition, Maven's plugin mechanism is completely dependent on the Maven lifecycle, so understanding the lifecycle is critical.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325985639&siteId=291194637