2. Preface
This article is mainly about Jersey experience. You will experience the charm of Jersey framework without doing any coding! This article also assumes that you have the Maven plug-in installed in eclipse!
Three steps
1. Create a new Maven project
2. Select the Maven prototype of the project (jersey-quickstart-grizzly), this is based on the 1.7 version of Jersey
3. Fill in the project information of this project and click "Finish" after filling in
4. You can see that the project is being generated in the lower right corner of the Eclipse address bar
5. The generated project structure is as shown below, among which Main.java is a small Java application launched by grizzly web server.
MyResource is the first REST Resource class that is automatically generated, including a simple GET request for resources.
6. Execute Main.java, grizzly web server will start.
7. Visit http://localhost:9998/application.wadl, as shown in the figure below. This is the generated REST resource description language
8. Visit the generated test resources, as shown in the figure below , seeing "Got it" means you have successfully experienced Jersey's first Hello World program!
Summary:
1. Currently, most open source projects are managed using Maven. Being able to master Maven is essential for learning an open source project, otherwise you won’t know how to start!
2. Using Maven can automatically download the source code and Javadocs corresponding to the Jar. This provides an easy way to deeply study an open source project. Otherwise, after downloading the binary jar, you have to find the source code, which is not only a waste of time, but also may be found. The source code does not match the version.
3. It is best to use the Eclipse maven plug-in. Some operations can be performed visually, which is much simpler than the command line. Otherwise, you have to remember a lot of commands, which is also very troublesome. I understand this deeply! I hope everyone can get started as soon as possible and avoid detours.
For more articles related to the first experience of Jersey framework, please pay attention to the PHP Chinese website!