Java JAX-RS RESTful service, jax-rsrestful

Source: Internet
Author: User

Java JAX-RS RESTful service, jax-rsrestful

There are many ides that can be used to develop Java RESTful services, Eclipse, NetBeans, etc. For personal preferences, use NetBeans. This article introduces the steps for getting started with NetBeans development.

The three articles "Understanding RESTful architecture", "RESTful API design guide", and "RESTful API design best practices" are typical articles about RESTful architecture, if you are interested in RESTful, read it.

The Reading Notes I 've also compiled are on GitHub: https://github.com/yulongyz/Reading/blob/master/RESTful.md

RESTful is an architectural style, or API style, JAX-RS is the RESTful standard of Java language, jersey is the open source implementation of JAX-RS, there are a variety of implementation solutions for JAX-RS, This paper introduces jersey implementation.

Quick Development Process with NetBeans

1. Download and install JDK and NetBeans and start NetBeans. I use version 8.0.

2. Create a project and select Java Web => Web application:

3. Next, select the server and Java EE version. jersey is a sub-project under GlassFish, so GlashFish supports jersey by default:

4. After creating a project, create a new RESTful service, select a Web service, and create a REST-style Web Service through the entity class. The other options will be discussed later:

5. The framework class of the RESTful service will be automatically generated later. By default, Get and Put calls are called. You can implement your own business logic based on this class.

I generally do not use "creating restful Web services through databases", and use Hibernate as the persistence layer in projects.

Tomcat deployment of RESTful services

Deployment after development is also very simple, mainly involving Configuration Modification and Database Import:

1. Modify the project's web. xml and add servlet ing:

<?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>            30        </session-timeout>    </session-config>    <welcome-file-list>        <welcome-file>index.html</welcome-file>    </welcome-file-list></web-app>

2. To deploy Tomcat, you need to add the jersey jar package, select the library, right-click the library, and add jersey:

3. Clean up and build, generate a war package, and copy it to Tomcat to complete the deployment.

Record, for better yourself!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.