【问题标题】:Which dependencies do I need for Jersey 2.5.1 @JSON and @JSONP Annotations?Jersey 2.5.1 @JSON 和 @JSONP 注释需要哪些依赖项?
【发布时间】:2014-02-14 02:02:21
【问题描述】:

我正在使用带有 Glassfish 4.0 的 Netbeans 7.4。 我尝试遵循一些在线教程,但我被困在这一点上:

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

Netbeans 找不到@JSONP 注释。我必须添加哪个依赖项才能解决此问题?

【问题讨论】:

  • 可能是this one。谷歌<your class> jar.
  • 不,这是不同的东西。不过感谢您的尝试。

标签: java glassfish jersey glassfish-4 jersey-2.0


【解决方案1】:

依赖项包含在 GlassFish 库中。

将 GlassFish 库添加到您的项目类路径中,或者如果您使用 Maven,请将以下依赖项添加到您的 pom.xml

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

Jersey Docs中所述:

如果您使用任何 Jersey 特定功能,则需要依赖 直接在泽西岛。

<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>

另请参阅:

【讨论】:

    猜你喜欢
    • 2014-02-24
    • 2016-09-28
    • 2018-09-20
    • 1970-01-01
    • 2019-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-23
    相关资源
    最近更新 更多