This project is a small example to show how to use Jersey and Spring in an embedded Jetty container. There are only a couple things required:
-
Make sure you have the
jersey-spring4
dependency. The spring4 dependency is new in Jersey 2.26. Prior versions usejersey-spring3
which uses Spring 3, instead of Spring 4. You can check out the pom.xml from this Stack Overflow post if you're usingjersey-spring3
and you want to use Spring 4. -
You just need to register a
ContextLoaderListener
equipped with aWebApplicationContext
that has your Spring context configuration (seeMain
class in project).
mvn clean install
mvn clean test
mvn exec:java
curl http://localhost:9090/greeting/en/{name}
curl http://localhost:9090/greeting/es/{name}