mvn command

mvn clean install -Dmaven.test.skip

[INFO] ------------------------------------------------------------------------
[INFO] Building demo-base 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2
[INFO]
[INFO] ---maven-clean-plugin:2.5:clean (default-clean) @ demo-base --- 
[INFO] Deleting /Users/xiude/IdeaProjects/spring-boot-demo-hb/demo-base/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demo-base ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 15 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5:compile (default-compile) @ demo-base ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 43 source files to /Users/xiude/IdeaProjects/spring-boot-demo-hb/demo-base/target/classes
[INFO] /Users/xiude/IdeaProjects/spring-boot-demo-hb/demo-base/src/main/java/com/alibaba/xiude/base/template/generator/ServiceMapperGenerator.java: /Users/xiude/IdeaProjects /spring-boot-demo-hb/demo-base/src/main/java/com/alibaba/xiude/base/template/generator/ServiceMapperGenerator.java uses or overrides an obsolete API.
[INFO] /Users/xiude/IdeaProjects/spring-boot-demo-hb/demo-base/src/main/java/com/alibaba/xiude/base/template/generator/ServiceMapperGenerator.java: For more information, use -Xlint:deprecation Recompile.
[INFO] /Users/xiude/IdeaProjects/spring-boot-demo-hb/demo-base/src/main/java/com/alibaba/xiude/base/template/generator/ServiceMapperGenerator.java: /Users/xiude/IdeaProjects /spring-boot-demo-hb/demo-base/src/main/java/com/alibaba/xiude/base/template/generator/ServiceMapperGenerator.java uses an unchecked or unsafe operation.
[INFO] /Users/xiude/IdeaProjects/spring-boot-demo-hb/demo-base/src/main/java/com/alibaba/xiude/base/template/generator/ServiceMapperGenerator.java: For more information, use -Xlint:unchecked Recompile.
[INFO]
[INFO] --- lombok-maven-plugin:1.16.8.0:delombok (default) @ demo-base ---
[WARNING] Skipping Delombok; no source to process.
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ demo-base ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5:testCompile (default-testCompile) @ demo-base ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ demo-base ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ demo-base ---
[INFO] Building jar: /Users/xiude/IdeaProjects/spring-boot-demo-hb/demo-base/target/MavenDemo.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ demo-base ---
[INFO] Installing /Users/xiude/IdeaProjects/spring-boot-demo-hb/demo-base/target/MavenDemo.jar to /Users/xiude/.m2/repository/com/alibaba/xiude/demo-base/1.0.0-SNAPSHOT/demo-base-1.0.0-SNAPSHOT.jar
[INFO] Installing /Users/xiude/IdeaProjects/spring-boot-demo-hb/demo-base/pom.xml to /Users/xiude/.m2/repository/com/alibaba/xiude/demo-base/1.0.0-SNAPSHOT/demo-base-1.0.0-SNAPSHOT.pom
[INFO]

Execution order:

1. Use the cleaning plugin: maven-clean-plugin: 2.5 Perform cleaning and delete the existing target directory;

2. Use resource plug-ins: maven-resources-plugin: 2.6 Execute the processing of resource files;

3. Use the compile plugin: maven-compiler-plugin:3.5 compile all source files to generate class files to the target\classes directory;

4. Use the resource plugin: maven-resources-plugin: 2.6 Execute the processing of the test resource file;

5. Use the compilation plugin: maven-compiler-plugin:3.5 to compile all the source code in the test directory;

6. Use the plugin: maven-surefire-plugin: 2.12.4 to run the test case;

7. Use the plugin: maven-jar-plugin: 2.4 to package the files generated after compilation. The default package name is: artifactId-version, such as the jar file generated in this example: demo-base-1.0.0-SNAPSHOT, package file Save it in the target directory;

8. Use maven-install-plugin: 2.4 to install the jar package and pom file generated by the above packaging into the local warehouse

Note: Steps 4 5 6 only work when mvn clean install

mvn package

Package is to put the jar under the target of this project, which is similar to mvn clean install, but omits step 8. When installing, install the jar under the target to the local warehouse for use by other projects.

mvn idea:idea

Automatically generate an idea project project, including executing three goals of project, module, and workspace

maven scope

Scope=compile, if nothing is filled in, the default is compile, which has the strongest dependency transfer, and is required for compilation, packaging, and running. It usually needs to be included when packing.

scope=provided, dependencies will not be passed, and will not be imported when generating war or jar packages. Compile only, useful for testing. For example, servlet-api, which has been provided by the container, can no longer be included, otherwise, exceptions such as package conflicts will be caused. For example, if aspectjweaver is set to provided in the demo-base, then the jar of aspectjweaver will not be automatically imported when other applications use demo-base-1.0.0-SNAPSHOT.

<dependency>
   <groupId>aspectj</groupId>
   <artifactId>aspectjweaver</artifactId>
   <scope>provided</scope>
</dependency>

scope=runtime, no dependencies at compile time, dependencies at runtime

scope=test, the dependent project only participates in the work related to the test, including the compilation and execution of the test code. More typical such as junit

scope=system, import the jar from the local repository, not the remote repository.

mvn loading of jar

mvn chooses the order in which to load the jars:

1. Select the version specified under <dependencyManagement> first;

2. If there is no version declaration, maven selects the package with the shortest path in the dependency tree;

3. If the length of the path is the same, it will be loaded according to the principle declared first;

As shown in the figure, if the definition 5.0.1 is displayed in pom.xml, then mvn will select this version

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>5.0.1</version>
</dependency>

If no definition is displayed, from demo-base to 5.0.4 path=2, to 5.0.1 path=1, 5.0.1 (the shortest path) will be preferred, and if the definition is as follows, 5.0.1 will be loaded (the first declared the rules)

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>5.0.1</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>5.0.4</version>
</dependency>

Jar package loading order

 The loading path where the Jar package is located is essentially the hierarchical structure where the class loader that loads the Jar package is located in the loader tree structure. The JVM class loader adopts the parent delegation mechanism. The higher the level of the class loader, the priority to load the classes in its loading path. Loading order: Startup class loader > extension class loader > system class loader (application loader). Assuming that two class files with the same package name and class name are not in the same jar package, if a class file has been loaded into the java virtual machine, the same class file will not be loaded.

File load order for the file system. Because the Classloader of containers such as Tomcat obtains the file list in the return order of the loading path, it is not sorted and depends on the return order of the system's file system. For Linux systems, it depends on the order of iNodes. Therefore, there may be problems with different running results between different machines in daily, pre-launch, and online.

Guess you like

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