用Jersey构建RESTful服务7--Jersey+SQLServer+Hibernate4.3+Spring3.2

Posted brucemengbm

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用Jersey构建RESTful服务7--Jersey+SQLServer+Hibernate4.3+Spring3.2相关的知识,希望对你有一定的参考价值。

一、整体说明

本例执行演示了用 Jersey 构建 RESTful 服务中。怎样集成 Spring3

二、环境

  • 1.上文的项目RestDemo
  • 2.Spring及其它相关的jar ,导入项目
    技术分享

三、配置

1.根文件夹下下创建 Spring 的配置文件applicationContext.xml
配置例如以下:

四、执行

1.先执行项目

2.执行UserClient.java測试,控制台输出例如以下

****添加用户addUser****
****查询全部getAllUsers****
[{"userId":"002","userName":"sdfs","age":"23"},{"userId":"003","userName":"sdfs","age":"23"},{"userId":"004","userName":"sdfs","age":"23"},{"userId":"005","userName":"sdfs","age":"23"},{"userId":"006","userName":"Susan","age":"21"},{"userId":"007","userName":"sdfs","age":"23"},{"userId":"ds","userName":"ds","age":"ds"}]
****改动用户updateUser****
****依据id查询用户****
006Susan33
****查询全部getAllUsers****
[{"userId":"002","userName":"sdfs","age":"23"},{"userId":"003","userName":"sdfs","age":"23"},{"userId":"004","userName":"sdfs","age":"23"},{"userId":"005","userName":"sdfs","age":"23"},{"userId":"006","userName":"Susan","age":"33"},{"userId":"007","userName":"sdfs","age":"23"},{"userId":"ds","userName":"ds","age":"ds"}]
****删除用户****
****查询全部getAllUsers****
[{"userId":"002","userName":"sdfs","age":"23"},{"userId":"003","userName":"sdfs","age":"23"},{"userId":"004","userName":"sdfs","age":"23"},{"userId":"005","userName":"sdfs","age":"23"},{"userId":"007","userName":"sdfs","age":"23"},{"userId":"ds","userName":"ds","age":"ds"}]

本章源代码(含jar包)https://github.com/waylau/RestDemo/tree/master/jersey-demo7-sqlserver-hibernate-spring3




以上是关于用Jersey构建RESTful服务7--Jersey+SQLServer+Hibernate4.3+Spring3.2的主要内容,如果未能解决你的问题,请参考以下文章

用Jersey构建RESTful服务5--Jersey+MySQL5.6+Hibernate4.3

用Jersey构建RESTful服务7--Jersey+SQLServer+Hibernate4.3+Spring3.2

用Jersey+spring+hibernate构建RESTful服务

jersey+maven构建restful服务

使用 Jersey 和 Apache Tomcat 构建 RESTful Web 服务

jersey + tomcat 实现restful风格