I'm using Netbeans 7.4 with Glassfish 4.0. I tried to follow some online tutorials, but I am stuck at to this point:

@GET
@JSONP
@Produces({"application/json", "application/javascript"})
public JaxbBean getSimpleJSONP() {
    return new JaxbBean("jsonp");
}

Netbeans cannot find the @JSONP annotation. Which dependency do I have to add to resolve this problem?

有帮助吗?

解决方案

The dependencies are included in the GlassFish libs.

Either add the GlassFish libs to your projects classpath or if you use Maven add the following dependency to your pom.xml:

<dependency>
    <groupId>org.glassfish.main.extras</groupId>
    <artifactId>glassfish-embedded-all</artifactId>
    <version>4.0</version>
        <scope>provided</scope>
</dependency>

As stated in the Jersey Docs:

If you are using any Jersey specific feature, you will need to depend on Jersey directly.

<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-servlet</artifactId>
    <version>2.5.1</version>
    <scope>provided</scope>
</dependency>
<!-- if you are using Jersey client specific features -->
<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>2.5.1</version>
    <scope>provided</scope>
</dependency>

See also:

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top