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
);
}
}
|
大功告成.
如果升级不成功请联系本人!