First, the overall description
This example performs a demonstration of building a RESTful service with Jersey. How to integrate Spring3
Second, the environment
- 1. The above item Restdemo
- 2.Spring and other related jars, importing the project
Third, the configuration
1. Create a Spring configuration file under the root folder applicationContext.xml
;
Configuration such as the following:
Iv. implementation
1. Execute the project first
2. Perform Userclient.java test, console output such as the following
Add User adduser******** query all getallusers****[{"userid": "002", "UserName": "SDFs", "Age": "},{", "userid": "003", " UserName ":" SDFs "," Age ":" All "},{" userid ":" 004 "," UserName ":" SDFs "," Age ":"},{"," userid ":" 005 "," UserName ":" SDFs "," Age ":"},{"userid": "006", "UserName": "Susan", "Age": "+"},{"userid": "007", "UserName": "SDFs", "Age": "23"},{" UserId ":" DS "," UserName ":" DS "," Age ":" DS "}]**** change user updateuser******** by ID query user ****006susan33**** query all getallusers** **[{"userid": "002", "UserName": "SDFs", "Age": "All"},{"userid": "003", "UserName": "SDFs", "Age": "All"},{"userid": "004" , "UserName": "SDFs", "Age": "},{", "userid": "005", "UserName": "SDFs", "Age": "},{", "userid": "006", "UserName": "Susan "," Age ":"},{"," userid ":" 007 "," UserName ":" SDFs "," Age ":" All "},{" userid ":" DS "," UserName ":" DS "," Age ":" DS "}]**** Delete User ******** query all getallusers****[{"userid": "002", "UserName": "SDFs", "Age": "},{", "userid": "003", "UserName": "SDFs "," Age ":"},{"," userid ":" 004 "," UserName ":" SDFs "," Age ":" All "},{" userid ":" 005 "," UserName ":" SDFs "," Age ":" 23 "},{" UserId ":" 007 "," UserName":" SDFs "," Age ":"},{"," UserId ":" DS "," UserName ":" DS "," Age ":" DS "}]
This chapter source code (including Jar package): Https://github.com/waylau/RestDemo/tree/master/jersey-demo7-sqlserver-hibernate-spring3
Building restful services with Jersey 7--jersey+sqlserver+hibernate4.3+spring3.2