5

I am working through examples in Restful Java with JAX-RS by Bill Burke. I'm using intellij and created a Maven project to make a "Hello World" web service. I understand that JAX-RS is a specification, and not an implementation. I would like to try the Apache CXF implementation.

How do I find out what jar, or what Maven artifact contains the necessary classes to:

import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.GET;
David Williams
  • 8,388
  • 23
  • 83
  • 171
  • 1
    Google can help you. A quick search got me among others http://aredko.blogspot.com/2013/01/going-rest-embedding-jetty-with-spring.html which provide samples (you an try newer version of the plugins) – JScoobyCed Aug 09 '13 at 01:57
  • 1
    Great. This was the one I was looking for. Java hardcores seem to know about it, but Im not sure how you find out an artifact like that has the package your looking for. How would I have found that on my own (ie without knowing about cxf)? I know there is find jars, but that only listed jersey. In general I want to get better at finding maven artifacts for certain classes. Does anything make that easier? – David Williams Aug 09 '13 at 02:20
  • Yes, the two proposed answer are what we all do. If you don't know what implementation to use, you need to google/yahoo to list the various implementation (and read what their limitation/support/dependencies/ease of use), then search on maven-oriented search sites like Central (search.maven.org) – JScoobyCed Aug 09 '13 at 02:24
  • 1
    Interesting, thanks. Sounds like a slightly daunting task, faster in groups of people probably. I grabbed cxf-rt-frontend-jaxrs and am giving it a try. That blog post is great btw, thanks for that. – David Williams Aug 09 '13 at 02:27
  • 1
    Central is your friend. You can go there and search for a class name or an artifact name for nearly any open-source project, and it's defined in the Maven super POM, so anything that's on there just requires adding the dependency. – chrylis -cautiouslyoptimistic- Aug 09 '13 at 02:31

3 Answers3

13

Add below lines in pom.xml

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0</version>
</dependency>
Vivek Bansal
  • 2,471
  • 2
  • 19
  • 24
4

Try searching for the class on Central. It looks like jaxrs-api is what you're looking for; there are a couple of different packagers, and which one you want is probably whichever goes with your container.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152
4

g:"javax.ws.rs" AND a:"jsr311-api"

http://search.maven.org/

Zac
  • 51
  • 2