当前位置:网站首页>Analysis of POM files
Analysis of POM files
2022-04-23 04:49:00 【wyplj_ sir】
List of articles
POM
maven The core of the project is pom.xml,POM(Project Object Model, Project object model ) Define the basic information of the project , Used to describe how a project builds , Declare project dependencies, etc .
Following pair pom A brief introduction to some of the tags :
xml
It's time to xml Version and encoding of the document
project
It's all pom.xml Of Root element , It also states some POM Related namespace and xsd Elements , These attributes are not required , But it can make IDE Medium XML Editors help developers quickly edit POM.
modelVersion
Specify the current POM The version of the model , about Maven2 and Maven3, The value of the tag is 4.0.0.
gav
groupId Is the name of the company organization ;artifactId Module name , The only in the group ID、version It's the version number . These three elements define the basic coordinates of a project , Any jar、pom perhaps war They are distinguished based on these basic coordinates .
name
Used to declare a more user-friendly project name ( Not necessary )
packaging
Specify the packaging type of the project :pom、jar、war.
Use maven Module division management , There is usually a parent project ,pom Except for GAV(groupId, artifactId, version) It must be configured , Another important attribute is packaging Packaging type , Of all parent projects packaging All for pom,packaging Default type jar type , If not configured ,maven The project will be printed as jar package . As a parent project , There is also an important attribute , That's it modules, adopt modules Tags refer to all subprojects of a project , stay build Parent project , I'll sort out a build The order , And then in turn build.
For each sub project , Need to be in its corresponding pom The beginning of the file declares a reference to the parent project , adopt GAV Realization . For your own... In the subproject GAV To configure ,GV If you don't configure , It will inherit from the configuration of the parent project . Sub modules can be through dependencies Tag to add your own dependencies , The other subclass items are packaging Value can only be war or jar. If it is a project to be deployed , Generally, it contains controller Of module, It needs to be packed into war type , If it's just internal call or service use , It is recommended to mark it as jar package , It's for war Bag , be located war In bag lib Under the folder .
parent
Contains the information required by the parent project to be inherited , The elements in the tag except gva outside , There is another element relativePath, Used to mark the parent project pom Relative location of documents .
If the project belongs to the child project of the parent project ( That is, the sub project folder is in the parent project folder ), The starting point of the folder is the current pom.xml Catalogue of the project to which it belongs , The default value is …/pom.xml, be relativePath Take the default value . If the project is a peer project of the parent project ( That is, the folders of the parent project and the child project are in the same directory ), It is necessary to display the... Indicating the parent project pom.xml The location of .
The search order is :relativePath The address in the element – Local repository – Remote warehouse
Setting a null value will always get it from the warehouse , Not from local path
module
This tag is in the parent project pom.xml Indicates the location of the submodule in , Based on the folder where the current parent project is located , Fill in the path of the sub module relative to . If it is a child project of the parent project , Then fill in the folder name directly .
properties
stay properties The version number can be declared as a variable in the tag , convenient maven Dependency tags are used for ${ Variable name } Get the version number dynamically in the form of . The advantage of this is that when the version number changes , Just need to update properties Just the variable value in the tag , Don't bother to update all dependent version numbers .
dependency
Specific dependencies
dependencyManagement and dependencies
Both are labels for managing dependencies , The difference between the two is as follows :
dependencies: Introduce automatic declaration in dependencies All the dependencies in , It is inherited by all subprojects by default . If no dependencies are written in the project , Will inherit from the parent project ( All properties inherit ) Declared in the parent project dependencies Dependencies in .
dependencyManagement It's just a statement of dependency , No introduction , Therefore, subprojects need to explicitly declare the required dependencies . If you don't declare dependencies in subprojects , Will not inherit from the parent project ; Only the dependency is written in the subproject , And no specific version was specified , Will inherit the item from the parent project , also version and scope Read from parent pom; If the version number is specified in the subproject , Then the version specified in the subproject is used .
dependencyManagement Let subprojects reference dependencies , Instead of displaying the version number listed .
Maven Will go up the father and son level , Until you find someone who has dependencyManagement Elements of the project , Then it will be used in this dependencyManagement The version number specified in the element , The dependencies used by all subprojects are the same version .
dependencyManagement Medium dependencies Does not affect project dependencies ; And independence dependencies Element affects the dependencies of the project . Only when the outer layer dependencies When the version information is not specified in the element ,dependencyManagement Medium dependencies Elements work . One is project dependency , One is maven When the project is multi module, it depends on management control .
dependencyManagement and dependencies
pom In the document dependencyManagement and dependency
distributionManagement
To configure : Use distribution management to type the project into jar package , Upload to the designated server
repository
Official version ,id Element is the user name in the server
snapshotRepository
Development version ,id Element is the user name in the server
build and profiles
版权声明
本文为[wyplj_ sir]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220555178561.html
边栏推荐
- 敏捷实践 | 提高小组可预测性的敏捷指标
- Recommended scheme for national production of electronic components of wireless keyboard
- Unity摄像头跟随鼠标旋转
- The last day of 2021 is the year of harvest.
- Recommended scheme of national manufactured electronic components
- [paper reading] [3D target detection] point transformer
- QML advanced (IV) - drawing custom controls
- What is a blocking queue? What is the implementation principle of blocking queue? How to use blocking queue to implement producer consumer model?
- leetcode002--将有符号整数的数字部分反转
- Implementation of switching windows and capturing data in selenium mode
猜你喜欢
What is a data island? Why is there still a data island in 2022?
Eight misunderstandings that should be avoided in data visualization
Repair of self calibration SPC failure of Tektronix oscilloscope dpo3054
[paper reading] [3D target detection] point transformer
Innovation training (IV) preliminary preparation - server
Unity rawimage background seamlessly connected mobile
CLion+OpenCV identify ID number - detect ID number
Innovation training (IX) integration
Sword finger offer: the path with a certain value in the binary tree (backtracking)
程序员抱怨:1万2的工资我真的活不下去了,网友:我3千咋说
随机推荐
[paper reading] [3D object detection] voxel transformer for 3D object detection
L2-011 play binary tree (build tree + BFS)
Innovation training (V) configuration information
leetcode001--返回和为target的数组元素的下标
What is a data island? Why is there still a data island in 2022?
PHP+MySQL 制作留言板
The unity camera rotates with the mouse
Graduation project
What's the difference between error and exception
The object needs to add additional attributes. There is no need to add attributes in the entity. The required information is returned
Eight misunderstandings that should be avoided in data visualization
Logger and zap log Library in go language
拼了!两所A级大学,六所B级大学,纷纷撤销软件工程硕士点!
test
Key points of AWS eks deployment and differences between console and eksctl creation
Jetpack -- lifecycle usage and source code analysis
Special topic of data intensive application system design
Installation and deployment of Flink and wordcount test
leetcode005--原地删除数组中的重复元素
Open the past and let's start over.