jersey 1.9.1 升级到 2.7

1.配置修改

jersey 1.9.1配置

jersey 1.9.1
def jerseyVersion = "1.9.1"          
compile "com.sun.jersey:jersey-server:${jerseyVersion}",
         "com.sun.jersey:jersey-json:${jerseyVersion}",
         "com.sun.jersey:jersey-core:${jerseyVersion}",
         "com.sun.jersey:jersey-client:${jerseyVersion}",
         "com.sun.jersey.contribs:jersey-multipart:${jerseyVersion}",
         "com.sun.jersey.contribs:jersey-spring:${jerseyVersion}"

2.7  配置

jersey 2.7
compile "org.glassfish.jersey.core:jersey-server:2.7",
         "org.glassfish.jersey.media:jersey-media-json-jackson:2.7",
         "org.glassfish.jersey.core:jersey-client:2.7",
         "org.glassfish.jersey.ext:jersey-spring3:2.7"

2.web.xml 修改

web.xml
//修改后
< servlet >
     < servlet-name >restful</ servlet-name >
     < servlet-class >org.glassfish.jersey.servlet.ServletContainer</ servlet-class >
     < init-param >
         < param-name >javax.ws.rs.Application</ param-name >
         < param-value >*.*.JsonProviderConfig</ param-value >
     </ init-param >
     < load-on-startup >1</ load-on-startup >
</ servlet >
< servlet-mapping >
     < servlet-name >restful</ servlet-name >
     < url-pattern >/rest/*</ url-pattern >
</ servlet-mapping >

 

3.新增JsonProviderConfig.java 类

JsonProviderConfig
import org.glassfish.jersey.filter.LoggingFilter;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
public class JsonProviderConfig extends ResourceConfig {
     private static final Logger logger = LoggerFactory.getLogger(JsonProviderConfig. class );
     public JsonProviderConfig() {
         logger.info( "configured!!!!!" );
         // 服务类所在的包路径
         packages( "com.***.****" );
         // 打印访问日志,便于跟踪调试,正式发布可清除
         register(LoggingFilter. class );
         register(JacksonFeature. class );
     }
}


大功告成.

如果升级不成功请联系本人!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值