How to set up Jersey 2.22 in the project?

Asked

Viewed 412 times

2

I’m having a hard time setting up Jersey 2.22.1 on my web project that is deployed on the server Tomcat 8, that I’m developing in Netbeans. Note: I use Maven.

I have read and reread the documentation but does not fit in my development environment.

My question is how to set up the files pom.xml and web.xml.

1 answer

1

I got.

web xml.

    <servlet>
        <servlet-name>Jersey Web Application</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>meu.pacote.dos.recursos</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Jersey Web Application</servlet-name>
        <url-pattern>/webservice/*</url-pattern>
    </servlet-mapping>

pom.xml

<properties>
    ...
    <jersey.version>2.22.1</jersey.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.