使用CXF+spring+restful创建一个web的接口项目
来源:互联网 发布:电魂网络会被收购吗 编辑:程序博客网 时间:2024/05/15 01:08
此文为使用CXF+spring创建一个web的接口项目的下文,在其基础上添加restful功能
1、添加restful的所需jar包
jsr311-api-1.0.jar
CXF与JAX-RS版本对应问题,参考自:http://bioubiou.iteye.com/blog/1866871
CXF支持REST风格的Web服务:JAX-RS2.0(JSR-339)和JAX-RS1.1(JSR-311)的Java API。
CXF2.7.0支持JAX-RS2.0(不包括客户端API现在 - 引入的新功能,但注意CXF客户端API已经更新,支持新的过滤器,拦截器,异常类和响应API,再加上客户端的异步调用API)。
CXF2.6.x版本,在2.5.x,2.4.x和2.3.x的支持JSR-311 API1.1和JAX-RS1.1 TCK符合。
CXF2.2.x的支持JSR-311 API1.0和JAX-RS1.0 TCK标准。
CXF的2.1.x支持JSR-311 API0.8。
本文选择cxf-2.4.2.jar与jsr311-api-1.0.jar
2、开发restful服务
新建RestfulRegeditService.Java接口
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
新建RestfulRegeditServiceImpl.java接口
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
3、修改spring配置文件applicationContext.xml
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
4、部署到tomcat,运行,成功,界面下图:
5、源代码地址下载:
CXF+spring+restful创建一个web的接口项目源代码
6、其他参考资料
Spring整合CXF,发布RSETful 风格WebService
这篇文章是承接之前CXF整合spring的这个项目示例的延伸,所以有很大一部分都是一样的。关于发布CXF WebServer和Spring整合CXF这里就不再多加赘述了。如果你对Spring整合CXF WebService不了解,具体你可以参看这两篇文章:
http://www.cnblogs.com/hoojo/archive/2011/03/30/1999563.html
http://www.cnblogs.com/hoojo/archive/2012/07/13/2590593.html
如果你不了解restful风格的WebService,你可以参考:
http://www.oracle.com/technetwork/articles/javase/index-137171.html
SpringMVC对RESTful的支持:
http://www.cnblogs.com/hoojo/archive/2011/06/10/2077422.html
使用 Jersey框架,搭建RESTful WebService(这个也比较简单)
http://www.ibm.com/developerworks/cn/web/wa-aj-tomcat/
官方文档:http://jersey.java.net/nonav/documentation/latest/user-guide.html#d4e8
其中,比较常用的RESTful框架就有Jersey、Spring REST、CXF RESTful,这些都可以很好的整合Spring框架,发布也相当的简单。且简单、易用、易上手,文档也比较丰富。
- 使用CXF+spring+restful创建一个web的接口项目
- 使用CXF+spring+restful创建一个web的接口项目
- 使用CXF+spring+restful创建一个web的接口项目
- 使用CXF+spring+restful创建一个web的接口项目
- 使用CXF+spring创建一个web的接口项目
- 使用spring创建一个RESTful Web Service
- 在Eclipse中基于Spring+CXF搭建RESTful Web Service的Maven项目
- cxf框架Demo3(在web项目中创建接口的cxf服务)
- Spring Boot创建一个RESTful Web Service
- 使用Spring创建满足RESTful规范的Web Service
- CXF-10: CXF 与 Spring 的整合 之 使用别人暴露的 Web Service 接口
- 使用Spring来创建RESTful Web Services
- (五)CXF整合Spring发布RESTful风格的Web服务
- 开发基于CXF的 RESTful WebService web 项目 webservice发布
- 开发基于CXF的 RESTful WebService web 项目 webservice发布
- 用Spring+cxf 实现一个简单的restful webService
- cxf+spring自定义restful接口返回消息
- CXF+Spring搭建Restful接口服务
- java 中图形界面设计中 用不同按钮实现不同功能
- 算法笔记
- 一般系统恢复技术
- Problem C: 让动物们叫起来吧!
- css可继承的属性有哪些?
- 使用CXF+spring+restful创建一个web的接口项目
- Linux学习笔记(八)-基于AIX/Linux平台的项目开发
- 学习淘淘商城第五十课(使用SolrJ管理Solr集群)
- Problem D: 来开个书店吧
- 连接池中的maxIdle,MaxActive,maxWait参数
- SRIO PCIE AURORA三种高速协议的区别
- 转载 Mysql优化 Mysql占用内存优化 CPU多核多线程优化
- A
- 临近性度量方法选取总结