What is the purpose of including the jersey-bom import scoped dependency in a jersey project?

前端 未结 1 1769
予麋鹿
予麋鹿 2020-12-25 13:50

When generating a jersey based project using the jersey-quickstart-grizzly2 artifact

mvn archetype:ge         


        
相关标签:
1条回答
  • 2020-12-25 14:40

    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>
    
    0 讨论(0)
提交回复
热议问题