There are many Ides that can develop Java RESTful services, Eclipse, NetBeans, and so on, with personal preference for NetBeans, this article describes the introductory steps for using NetBeans development.
"Understanding RESTful architecture", "RESTful API Design Guide", "RESTful API design Best practices" are three articles that describe the classic of restful architecture, and recommend that you be interested in restful reading.
I also tidy up the reading notes on GitHub: https://github.com/yulongyz/Reading/blob/master/RESTful.md
RESTful is an architectural style, or API style, Jax-rs is the Java language of the RESTful standard, Jersey is jax-rs Open source implementation, for Jax-rs there are many implementations, this article is about jersey implementation.
Rapid development process with NetBeans
1, download install JDK, NetBeans, start NetBeans, I use 8.0 version.
2. New project, select Java web=>web application:
3, Next, select Server and Java EE version, Jersey is a sub-project under GlassFish, so glashfish support jersey by default:
4. Create a new project, create a new restful service, select a Web service, make a "RESTful Web service through entity class", and a few more options later:
5. After that, the framework class of the restful service will be generated automatically, the default get, put call, etc., based on this class to implement their own business logic.
I don't normally use hibernate as a persistence layer in my project by using "Create restful Web services from a database."
Tomcat Deployment for RESTful services
The deployment after development is also very simple, mainly related to configuration modification and library import:
1. Modify the project's Web. XML to increase the servlet mappings:
<?xml version= "1.0" encoding= "UTF-8"? ><web-app version= "3.1" xmlns= "Http://xmlns.jcp.org/xml/ns/javaee" Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "Http://xmlns.jcp.org/xml/ns/javaee Http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd "> <servlet> <servlet-name> Applicationconfig</servlet-name> <servlet-class>cn.zh.ApplicationConfig</servlet-class> </servlet> <servlet-mapping> <servlet-name>applicationconfig</servlet-name > <url-pattern>/*</url-pattern> </servlet-mapping> <session-config> <session-timeout> </session-timeout> </session-config> < welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
2, deploy to Tomcat need to add Jersey Jar package, select the Library, right-click Add Library, add Jersey:
3. Clean up and build the war package and copy it to Tomcat to complete the deployment.
Record, for the better of myself!
Rapid development of Java Jax-rs RESTful services with NetBeans