What is the purpose of including the jersey-bom import scoped dependency in a jersey project?(在 jersey 项目中包含 jersey-bom 导入范围依赖项的目的是什么?)
问题描述
当使用 中了解更多信息.
基本上,BOM 允许您根据需要添加任意数量的球衣依赖项,而无需担心混合不良版本:
<依赖><依赖性><groupId>org.glassfish.jersey.containers</groupId><artifactId>jersey-container-grizzly2-http</artifactId><!-- 因为 BOM,所以不需要版本 --></依赖><依赖性><groupId>org.glassfish.jersey.media</groupId><artifactId>jersey-media-json-jackson</artifactId><!-- 因为 BOM,所以不需要版本 --></依赖></依赖关系>
When generating a jersey based project using the jersey-quickstart-grizzly2
artifact
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:
<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:
What is the purpose of including the jersey-bom
dependency in the project ?
You should not delete the jersey-bom
from dependencyManagement
.
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.
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.
Basically, the BOM allows you to add as many jersey dependencies as you need without worrying about mixing bad versions:
<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>
这篇关于在 jersey 项目中包含 jersey-bom 导入范围依赖项的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 jersey 项目中包含 jersey-bom 导入范围依赖项的目的是什么?


基础教程推荐
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01