1. Background
Recently, more and more friends in Jersey's learning group have been asked very basic questions. I think this phenomenon is common. The reason is that most of the students who entered the group are beginners of Jersey, and even more so, maybe beginners of Java. They have entered the learning field of Jersey's framework with curiosity about REST webservice. However, because they are novice, they feel that tigers are unable to get their claws! In order to guide newbies to learn, I will write a few entry-level blogs about Jersey in the future, so stay tuned!
2. Preface
This article is mainly about Jersey experience, you will experience the charm of the Jersey framework without doing any coding! This article also assumes that you have installed the Maven plugin in eclipse!
3. Steps
1. Create a new Maven project
2. Select the project's Maven prototype (jersey-quickstart-grizzly), which is based on Jersey version 1.7
3. Fill in the project information of this project, click "Finish" after filling in it
4. You can see that the project is being generated at the bottom right of the Eclipse address bar.
5. The generated project structure is as shown in the figure below, where Main.java is a Java applet started by grizzly web server.
MyResource is the first REST Resource class that automatically generates, which contains a simple GET request resource.
6. Execute Main.java, and the 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. Access the generated test resources, as shown in the figure below, see "Got it", which means that you have successfully experienced Jersey's first Hello World program!
Summarize:
1. At present, most open source projects are managed using Maven. Being able to master Maven is crucial to learning an open source project, otherwise you won’t know how to start!
2. Use Maven to automatically download the source code and Javadocs corresponding to Jar, which provides a simple way to learn an open source project in depth. Otherwise, if you download a binary jar, you have to find the source code, which not only wastes time, but also may not match the version of the source code.
3. It is best to use the Eclipse maven plug-in. Some operations are executed visually, which is much simpler than the command line. Otherwise, you will have to remember many commands, which is also very troublesome. I have a deep understanding! I hope everyone can get started as soon as possible and avoid detours.