📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
✅ Some premium posts are free to read — no account needed. Follow me on Medium to stay updated and support my writing.
🎓 Top 10 Udemy Courses (Huge Discount): Explore My Udemy Courses — Learn through real-time, project-based development.
▶️ Subscribe to My YouTube Channel (172K+ subscribers): Java Guides on YouTube
Technologies and tools used
- Jersey 2.27
- JDK 1.8
- Tomcat 8.5
- Maven 3.0.3
- Eclipse Neon
Development Steps
- Create Maven Web Application Project
- Project Packaging Structure
- Update Jersey Dependencies in a Pom.Xml File
- Create Resource - HelloWorldResource.java
- Descriptor-Less Deployment Configuration
- Build and Deployment
- Conclusion
1. Create a Maven Web Application Project
2. Project Packaging Structure
3. Update Jersey Dependencies in a Pom.Xml File
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.javadevelopersguide.jersey</groupId>
<artifactId>jersey-helloworld-example</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>jersey-helloworld-example Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.7</version>
</dependency>
</dependencies>
<build>
<finalName>jersey-helloworld-example</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
</project>
4. Create Resource - HelloWorldResource.java
package com.javadevelopersguide.jersey.helloworld;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("/")
public class HelloWorldResource {
@GET
@Path("helloworld")
public String helloworld() {
return "Helloworld !!!!";
}
}
5. Descriptor-Less Deployment Configuration
package com.javadevelopersguide.jersey.config;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
@ApplicationPath("resources")
public class MyApplication extends ResourceConfig {
public JerseyServletContainerConfig() {
// if there are more than two packanges then separate them with semicolon
// exmaple : packages("org.foo.rest;org.bar.rest");
packages("com.javadevelopersguide.jersey.helloworld");
}
}
6. Build and Deployment
mvn clean install
clean install
Comments
Post a Comment
Leave Comment