Maven
- Maven repositories
- Quickly find jar packages and form dependent XML languages
- Project management tools, dependency management, build life cycle/phases
POM project Object ModelProject object Model- Repositories, storage resources, and various JAR packages
- Coordinates, the repository location in Maven
groupIdDefines the name of the organization to which the current Maven project belongsartifactIdDefines the current Maven project nameversionDefines the current project version numberpom.xmlExample file dependencies
<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.2.9.RELEASE</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId> The < version > 4.12 < / version > < / dependency > < / dependencies >Copy the code
warThe type is WebApp,jarThe type is default Java- Project build lifecycle
compile->test-compile->test->package->install
Rely on
- The path has a higher priority. The deeper the level, the lower the priority
- Declaration priority, same level, configuration order of the first overwrites the order of the last
- Special priority. Different versions of the same resource. The last one overrides the first one
- Optional dependencies, hidden dependencies
<optional>true</optional>
Copy the code
- Eliminate dependencies and disconnect actively
<exclusions>
<exclusion>
<groupId>juint</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
Copy the code
- Depend on the range
<scope>test</scope>
Copy the code
| scope | Main code | The test code | packaging |
|---|---|---|---|
| Compile (default) | Y | Y | Y |
| test | Y | ||
| provided | Y | Y | |
| runtime | Y | ||
| ## Maven lifecycle |
- Clean up
- Default core work, such as compilation, testing, packaging, and deployment
- Site generates reports and publishes sites
- Plug-ins, bound to phases within the lifecycle, perform the corresponding plug-in functions when they reach the corresponding lifecycle
<! -- Build --> <build> <! -- plugins --> <plugins> <! -- Plugin --> <plugin> <! Plugins </groupId> <artifactId> Maven-source-plugin </artifactId> Executions <goals> <goal>jar</goal> <goal>test-jar</goal> </goals> <phase>generate-test-resources</phase> </execution> </executions> </plugins> </build>Copy the code
Build management
- The package format is POM
<packaging>pom</packaging> - Manage updates to other modules with dedicated modules
- The order of calls is based on dependencies
<modules> <module> Module path <modeule> </modules>Copy the code
Rely on inheritance
- Declare dependency management, where all dependencies are placed, and manage dependency versions of other modules
<dependencyManagement></dependencyManagement>
Copy the code
- Plug-in management
<pluginManagement></pluginManagement>
Copy the code
- A managed project defines a parent project
<parent> <> File location <> <relativePath> Parent project POM file </relativePath> </parent>Copy the code
attribute
- Unified version: Manages the content of configuration files
<properties> <propertiy> <! </spring.version> </spring.version> </propertiy> </properties>Copy the code
- Add configuration files to build
<resources> <resource> <directory> Resource folder path </directory> <filtering>true</filtering> </resource> </resources>Copy the code
Multi-environment Configuration
// Environment <profiles> // an environment <profile> // Environment name <id>pro_env</id> // Environment configuration <properties> <junit.version>4.12</junit.version> </properties> // Default activation < Activation > <activeByDefault>true</activeByDefault> </activation> </profile> </profiles> // call Install -p Environment nameCopy the code
Skip the test
install -D skipTests- Maven window
ToogleLightning button - Pom file
< plugin > < artifactId > maven - surefire plugin < / artifactId > < version > 2.22.2 < / version > < configuration > <skipTests>true</skipTests> </configuration> </plugin>Copy the code
- Specify the test
<plugin> <artifactId> Maven-surefire-plugin </artifactId> <version>2.22.2</version> <configuration> <includes> <include>**/ Test class name </include> </includes> <excludes> </exclude> </configuration> </plugin>Copy the code
The Nexus private servers
- Download link
- Idea connects to the private server through the local repository
- Post to private server
<distributionManagement> <repository> < ID > Repository </ ID > < URL > address </ URL > </repository> </distributionManagement>Copy the code