ResourceConfig在泽西应用程序中抛出异常

时间:2014-04-15 19:44:46

标签: maven jersey

我无法找到导致问题的原因。它崩溃了新的ResourceConfig(HelloWorld.class); 有什么见解吗?

 ResourceConfig rc = new ResourceConfig(HelloWorld.class);
 HttpServer server = JdkHttpServerFactory.createHttpServer(endpoint, rc);

.........

Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Sets
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more

整个文件减去导入

@Path("/helloworld")
public class HelloWorld {
    static final String BASE_URI = "http://localhost/9999/";

    // The Java method will process HTTP GET requests
    @GET
    // The Java method will produce content identified by the MIME Media type "text/plain"
    @Produces("text/plain")
    public String getClichedMessage() {
        // Return some cliched textual content
        return "Hello World";
    }

    public static void main(String[] args) throws IOException,URISyntaxException{
       //ResourceConfig rc = new ResourceConfig(rest.Service.class);
        URI endpoint = new URI("http://localhost:9999");

        ResourceConfig rc = new ResourceConfig(HelloWorld.class);
        HttpServer server = JdkHttpServerFactory.createHttpServer(endpoint, rc);

        System.out.println("Server running");
        System.out.println("Visit: http://localhost:9999/helloworld");
        System.out.println("Hit return to stop...");
        System.in.read();
        System.out.println("Stopping server");
        server.stop(0);
        System.out.println("Server stopped");
    }
}

pom:

  <dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-jdk-http</artifactId>
        <version>2.7</version>
    </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>2.7</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.bundles.repackaged</groupId>
            <artifactId>jersey-guava</artifactId>
            <version>2.7</version>
        </dependency>
        <dependency>
            <groupId>com.google</groupId>
            <artifactId>google</artifactId>
            <version>5</version>
        </dependency>
    </dependencies>

1 个答案:

答案 0 :(得分:1)

依赖可能是

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>16.0.1</version>
</dependency>
相关问题