Create a Rest Web service using MAVEN, Jersey, and Google Protobuf. Windows7 32bit

Source: Internet
Author: User

1. This article refers to the link:

http://shijunjuan.iteye.com/blog/1812642 (mainly this link)

Http://sleeplessinslc.blogspot.com/2010/03/restful-representation-with-google.html (Another method)

Installation method of Proto BUF: http://www.cnblogs.com/xinsheng/p/3879145.html

Proto buf GitHub address: https://github.com/google/protobuf/blob/master/README.md

Tomcat Plugin: http://blog.csdn.net/seuxiaoqi/article/details/6003549

Tomcat download please handle it yourself! My version is 6.0.

The environment used is Windows Eclipse luna (32bit) JDK 1.8 maven (System comes with) Tomcat (6.0)

2. First create a Maven Project in eclipse:

This is the same as my main reference link configuration.

2. Create under the src file

Test

Test/java

Main/java

Three of folders

Create work folders for tomcat! in the entire project directory

After completion the entire project directory is as follows:

3. The entire project details:

Engineering Profile Pom.xml:(I use the proto version is 2.5.0 here is to download, I also have the project directory inside. Several times because I refer to someone else's project, the version of the Proto compiler I'm using is different from the version that Eclipse calls, so I can't run tangled for a long time. I hope you all notice

Server-side:

All of the deployment is server-side:

Where the DEMO.PB package is just used to generate the. java file using the Proto compiler. Here's how I refer to my main reference links:

Another way to do this is to use Maven-autorun-plugin to generate from Pom.xml. Search directly on Google to find!

Addressbookresource.java: Server-declared resource file can request server via get post

Addressbookstore.java is used to store a server-side small warehouse, where user-submitted data is put into the AddressBooks.txt file.

Addressbookprotos.java using the proto compiler generated files, I have not modified

In addition, I would like to say one of the two documents:

Protobufmessagebodyreader.java

Protobufmessagebodywriter.java

This is the PROTOBUF format server-side reader and Writer if all of the deployment is normal in Tomcat, Tomcat can find these two provider. I'll post it back in a moment.

Client:

This client is not connected to the entire project, but simply placed under a project.

The main idea is to access the server via URL, test commit, test get function.

Here is my project: (Put in Baidu Cloud)

Http://pan.baidu.com/s/1qWt4jSC

Where Jerseydemo is no maven

Jerseydemo3 has maven.

Experience:

This project is mainly how to configure the success

1. If your project will be red but you can not find where: try

Right-click Project-"Maven->update Project

2.tomcat configuration:

This is not the same as the general Tomcat project!

Create a Rest Web service using MAVEN, Jersey, and Google Protobuf. Windows7 32bit

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.