最近接触Jersey 浅谈一下

  这里用maven 建立Jersey 项目就不说了,

我把pom依赖的文件贴出来

<dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.3</version>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-json</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.3</version>
        </dependency>
        <dependency>

            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>3.2</version>
        </dependency>

        <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.5</version>
                <type>jar</type>
                <scope>provided</scope>
            </dependency>

黑体部分是必须依赖的

jersey-json 假如返回数据需要时json格式也是必须的依赖的   最后一个依赖是写测试用的

这里要说的是建成以后我这里出现的几个错误

报500错误的情况

SEVERE: Mapped exception to response: 500 (Internal Server Error)

1、pojo 类的方法没有注解 @XmlRootElement 或者类里面有List 对象 没有@XmlElement 注解

2、@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })   MIME的返回形式  假如只有 MediaType.APPLICATION_JSON  没有依赖jersey-json 包会报错


转载于:https://my.oschina.net/u/1262156/blog/349704

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值