一起使用Spring和Jersey [英] Using Spring and Jersey together

查看:136
本文介绍了一起使用Spring和Jersey的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个可以部署的小型独立RESTful API网络应用程序.我想将Spring用于依赖项注入,并将Jersey用于RESTful内容.

I want to create a small standalone RESTful API web-app which I can deploy. I want to use Spring for dependency injection and Jersey for the RESTful stuff.

这可以做吗?还是应该使用Spring使用的任何RESTful功能?

Is this something that can be done? Or should I be using whatever RESTful features that Spring uses?

如果可以同时使用Spring和Jersey,那么如何将它们组合在一起?我的web.xml需要包含什么?

If using both Spring and Jersey together makes sense, how do I combine them? What does my web.xml need to have in it?

推荐答案

您的web.xml应该包含jersey spring servlet

your web.xml should contain jersey spring servlet

<servlet>
        <servlet-name>Jersey REST Service</servlet-name>
        <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>com.vxl.appanalytix.service.impl</param-value>
        </init-param>
       <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey REST Service</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>

查看这些示例以获取更多详细信息 在球衣struts2 spring3上无法正常工作 球衣休息服务显示异常javax.ws.rs.WebApplicationException:javax.xml.bind.MarshalException

check these examples for more details rest with jersey struts2 spring3 not working jersey rest services showing exception javax.ws.rs.WebApplicationException: javax.xml.bind.MarshalException

这篇关于一起使用Spring和Jersey的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆