Coding Assistance for REST Development
Besides the common Web services support, IntelliJ IDEA provides the following facilities for developing RESTful Web services:
- Generating a sample Web service and deploying it locally
- Code completion for MIME type.
- Code inspections and quick fixes.
- REST Client tool window for testing RESTful Web services.
Generating a Sample Web Service
When you create a module for developing a RESTful WebService, you can have sample code of the server side generated.
IntelliJ IDEA creates a package with a
HelloWorld class that has the following methods:
main()method that creates an instance of a local HTTP server and starts it.
getClichedMessage()method that returns a cliched message. The method is supplied with the
Use this class as an example or populate it as necessary to develop and test your RESTful Web service. To start the sample Web service, choose or press Shift+F10. IntelliJ IDEA creates a local HTTP server, starts it, whereupon deploys and runs the Web service.
Code Inspection and Quick Fixes
|Issue||Default Quick Fix|
|Inconsistency between a method annotation and the method return type:
a ||Change to String.|
|Inconsistency between the class type and the type of a method within the class: a non-resource class contains resource methods.||Remove |
|A Root Resource Class does not contain resource methods.||Remove |
|Different Root Resource Classes have the same ||Remove |
|A ||Change to */*.|
REST Client Tool Window
Dedicated REST Client tool window supports:
- Constituting URL addresses semiautomatically from the specified Deployment point and the
- Submitting requests to the server.
- Displaying server responses in the Response tab.
- Code integration between the Java code and the contents of the REST Client window controls.
|Change in the Java code||Change in the REST Client tool window|
||The contents of the Path to resource drop-down list change.|
||The contents of the Accept drop-down list change.|