Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven dependencies needed for Jersey 2.x (2.6)

I'm trying to migrate from Jersey 1.x (1.2) to 2.x (2.6), I have trouble identifying the exact maven dependencies, jersey documentation is not comprehensive enough, it doesn't mention what maven dependencies are needed for the new version.

Does anyone have comprehensive list of maven dependencies needed for Jersey 2.x (2.6)?

Jersey doc https://jersey.java.net/documentation/latest/migration.html#mig-1.x

like image 404
Asela Senanayake Avatar asked Jan 12 '15 01:01

Asela Senanayake


People also ask

What are the Maven dependencies?

There are two types of dependencies in Maven: direct and transitive. Direct dependencies are the ones that we explicitly include in the project. On the other hand, transitive dependencies are required by direct dependencies. Maven automatically includes required transitive dependencies in our project.

Where can I find dependencies in Maven?

In your project's POM, press Ctrl and hover the mouse over the dependency. Click the dependency to open the dependency's POM. In the dependency POM, view the active dependency, its transitive dependencies and their versions. You can check the origin from which the dependency was pulled in.


1 Answers

For a servlet environment, the only dependency you need is

<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-servlet</artifactId>
    <version>2.6</version>
</dependency>

This will pull in all you need. If you are in a servlet 2.5 environment, then you would use this instead

<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-servlet-core</artifactId>
    <version>2.6</version>
</dependency>

Further information about 2.5 servlet, can be seen here

Alternatively, you could create a project from a Maven archetype, as seen here

UPDATE

Just as a note, the significance of using Jersey 2.6 is that it is the last version to support Java 6. If this is not a requirement for you, I would recommend using the latest version.

like image 110
Paul Samsotha Avatar answered Sep 27 '22 20:09

Paul Samsotha