When generating a jersey based project using the jersey-quickstart-grizzly2
artifact
使用jersey-quickstart-grizzly2工件生成基于球衣的项目时
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 \
-DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \
-DgroupId=com.example -DartifactId=simple-service -Dpackage=com.example \
-DarchetypeVersion=2.7
The pom generated a jersey-bom
dependency which can be deleted:
pom生成了一个可以删除的jersey-bom依赖项:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
And this dependency:
这种依赖:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
</dependency>
this is how the maven dependency graph looks like:
这就是maven依赖图的样子:
What is the purpose of including the jersey-bom
dependency in the project ?
在项目中包含jersey-bom依赖项的目的是什么?
1 个解决方案
#1
37
You should not delete the jersey-bom
from dependencyManagement
.
你不应该从dependencyManagement中删除jersey-bom。
A BOM (bill of materials) packages related dependencies so that their versions will work together. You can read more about it in the maven docs on this page.
BOM(物料清单)包相关的依赖关系,以便它们的版本一起工作。您可以在此页面上的maven文档中阅读有关它的更多信息。
Because this lives in dependencyManagement
(not in dependencies
), it is not actually adding dependencies to your project, it's just centralizing version management. If you are not familiar with the difference, read more in this SO answer.
因为它存在于依赖管理中(不在依赖项中),所以实际上并没有向项目添加依赖项,它只是集中了版本管理。如果您不熟悉这种差异,请阅读本SO答案中的更多内容。
Basically, the BOM allows you to add as many jersey dependencies as you need without worrying about mixing bad versions:
基本上,BOM允许您根据需要添加尽可能多的球衣依赖关系,而不必担心混合不良版本:
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<!-- NO VERSION NEEDED BECAUSE OF THE BOM -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<!-- NO VERSION NEEDED BECAUSE OF THE BOM -->
</dependency>
</dependencies>
#1
37
You should not delete the jersey-bom
from dependencyManagement
.
你不应该从dependencyManagement中删除jersey-bom。
A BOM (bill of materials) packages related dependencies so that their versions will work together. You can read more about it in the maven docs on this page.
BOM(物料清单)包相关的依赖关系,以便它们的版本一起工作。您可以在此页面上的maven文档中阅读有关它的更多信息。
Because this lives in dependencyManagement
(not in dependencies
), it is not actually adding dependencies to your project, it's just centralizing version management. If you are not familiar with the difference, read more in this SO answer.
因为它存在于依赖管理中(不在依赖项中),所以实际上并没有向项目添加依赖项,它只是集中了版本管理。如果您不熟悉这种差异,请阅读本SO答案中的更多内容。
Basically, the BOM allows you to add as many jersey dependencies as you need without worrying about mixing bad versions:
基本上,BOM允许您根据需要添加尽可能多的球衣依赖关系,而不必担心混合不良版本:
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<!-- NO VERSION NEEDED BECAUSE OF THE BOM -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<!-- NO VERSION NEEDED BECAUSE OF THE BOM -->
</dependency>
</dependencies>