What is POM? Pom as a Project object model. The MAVEN project is represented by XML and is implemented using Pom.xml. The main description of the project: including configuration files, developers need to follow the rules, defect management system, organization and licenses, project URL, project dependencies, and all other project-related factors.
Quick View: XML code <project> <modelVersion>4.0.0modelVersion> <groupId>...groupId> <artifactid >...artifactId> <version>...version> < packaging>...packaging> <dependencies>...dependencies> <parent>...parent> <dependencymanagement>...dependencymanagement > <modules>...modules> <properties> .... properties> <build>...build> <reporting>...reporting> <name>...name> <description>...description> <url>...url> <inceptionYear>...inceptionYear> < licenses>...licenses> <organization>...organization> <developers>...developers> <contributors>...contributors> <issueManagement>...issueManagement> <ciManagement>...ciManagement> <mailinglists> .... mailinglists> <scm>...scm> <prerequisites> ..... prerequisites> <repositories>...repositories> < pluginrepositories>...pluginrepositories> <distributionmanagement> distributionmanagement> <profiles>...profiles> project>
Basic content: The POM includes all the project information.
Maven Related:
The POM defines the smallest maven2 element, allowing for groupid,artifactid,version. All the required elements
GroupId: A unique flag for a project or organization, and the path generated by the configuration is generated, such as the relative path generated by Org.codehaus.mojo:/org/codehaus/mojo artifactid: Generic name version of the project: Project version Packaging: Packaged mechanisms such as POM, jar, Maven-plugin, EJB, War, Ear, RAR, par classifier: classification
Pom Relationship: Mainly for dependence, inheritance, synthesis
dependencies: XML code <dependencies> <dependency> <groupId>junitgroupId> <artifactid>j unitartifactid> <version>4.0version> <type>jartype> <scope>testscope> ; <optional>trueoptional> dependency> ... dependencies>
GroupId, Artifactid, version: A project unique flag that describes dependencies can be installed in the following ways:
Install using the following command: MVN install:install-file–dfile=non-maven-proj.jar–dgroupid=some.group–dartifactid=non-maven-proj– Dversion=1 to create your own library and configure it to use Deploy:deploy-file to set this dependency range to system, and to define a path to the systems. Not advocated. Type: The corresponding dependent product package form, such as Jar,war scope: used to limit the corresponding dependency range, including the following variables: Compile: Default scope, for compiling provided: similar to compilation, but support you expect JDK or container to provide, Similar to CLASSPATH Runtime: When executing, you need to use the system when using test: to provide the corresponding elements externally. Get Systempath by Systempath: only for scope system. Provides the appropriate path optional: Annotations are optional when the project itself is dependent. Used for continuous dependency
Exclusive Externally tell Maven that you include only the specified item, excluding dependent dependencies. This factor is primarily used to resolve version conflict issues
XML code <dependencies> <dependency> <groupId>org.apache.mavengroupId> <arti factid>maven-embedderartifactid> <version>2.0version> <exclusions> <excl Usion> <groupId>org.apache.mavengroupId> <artifactId>maven-coreartifactId> Exclusion> exclusions> dependency>
Indicates that project Maven-embedder requires project Maven-core, but we do not want to cite Maven-core
Inheritance Relationship Another powerful change that MAVEN brings is Project inheritance. The main settings:
Define Parent Project
XML code <project> <modelVersion>4.0.0modelVersion> <groupId>org.codehaus.mojogroupId> <artifactId>my-parentartifactId> <version>2.0version> <packaging>pompackaging> Proje Ct>
The packaging type requires POM for parent and for compositing multiple projects. We need to add the corresponding value to the parent POM for child project inheritance. The main elements are as follows:
Dependency developer and Partner plug-in list report List plugin execution use matching IDs plug-in configuration sub-project configuration XML code <project> <modelVersion>4.0.0modelVersion> <parent> <groupId>org.codehaus.mojogroupId> <artifactId>my-parentartifactId> &L T;version>2.0version> <relativepath> /my-parentrelativepath> parent> <artifactId>my-projectartifactId> project>
RelativePath can be used without, but used to indicate parent's directory for quick queries.
dependencymanagement: For the parent project configuration Common dependencies, the main configuration depends on the same factors as the package, such as version, scope.
compositing (or multiple modules) A project has multiple modules, also called multiple modules, or synthetic projects.
As the following definition:
XML code <project> <modelVersion>4.0.0modelVersion> <groupId>org.codehaus.mojogroupId> <artifactId>my-parentartifactId> <version>2.0version> <modules> <MODULE>MY-PR oject1<module> <module>my-project2<module> modules> project>
Build Settings Mainly used for compiling settings, including two main elements, build and the
Build It is divided into two parts: a set of basic elements and extended elements
Note: Include project build and profile build
XML code <project> <build>...build> <profiles> <profile> &L t;build>...build> profile> profiles> project>
Basic elements
XML code <build> <defaultGoal>installdefaultGoal> <directory>${basedir}/targetdirectory> <finalName>${artifactId}-${version}finalName> <filters> <filter>filters/filter1.properti Esfilter> filters> ... build>
Defaultgoal: Defines the default target or phase. such as install directory: Compile the output of the directory Finalname: Generate the final file style filter: Define filtering, to replace the corresponding property file, using the properties defined by Maven. Set values for all Placehold
resource (resources) The resources you need to specify in your project. such as the spring configuration file, log4j.properties
XML code <project> <build> ... <resources> <resource > <targetpath>meta-inf/plexustargetpath > <filtering>falsefiltering> <directory>${basedir}/src/main/plexusdirectory> <includes> <include>configuration.xmlinclude> includes> <excludes> <exclude>**/*. Propertiesexclude> excludes> resource> resources> <testResources> ... testResources> ... build> project>
A list of resources:resource that is used to include all resources TargetPath: Specify a target path, for placing resources, for build filtering: whether to replace attributes in a resource Placehold directory: where resources are located Includes: styles, including those resources
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.