Jersey Standalone
Compact self-sufficient JAX-RS distribution based on Grizzly and Jersey.
Quick start
- Add Maven dependency
<dependency>
<groupId>com.github.skapral.jersey.se</groupId>
<artifactId>jersey-se</artifactId>
<version>x.y.z</version>
</dependency>
- Define JAX-RS resource config
public class SimpleConfig extends ResourceConfig {
/**
* Ctor.
*/
public SimpleConfig() {
super(
StatusEndpoint.class
);
}
}
@Path("status")
public class StatusEndpoint {
/**
* @return returns "OK"
*/
@GET
@Produces(MediaType.TEXT_PLAIN)
public String status() {
return "OK";
}
}
- Define entry point.
public static void main(String... args) throws Exception {
new SrvGrizzlyWithJersey(
new Cp_PORT(),
new SimpleConfig()
).start();
System.in.read(); // Server instance uses daemon threads, so hold
// main thread until you need the server online.
}
- Run the instance.