IntelliJ IDEA 13.1 Web Help

Besides the common Web services support, IntelliJ IDEA provides the following facilities for developing 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:

  • The main() method that creates an instance of a local HTTP server and starts it.
  • The getClichedMessage() method that returns a cliched message. The method is supplied with the @Path, @GET, and @Produces annotations.

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 Run | Run or press Shift+F10Shift+F10Shift+F10Shift+F10Shift+F10F9Ctrl+F5F6Shift+Alt+X or Shift+F10Control RShift F10Shift Command F11. IntelliJ IDEA creates a local HTTP server, starts it, whereupon deploys and runs the Web service.

Code inspection and quick fixes

IntelliJ IDEA supports code inspections and suggests quick fixes in the following cases:

Issue Default Quick Fix
Inconsistency between a method annotation and the method return type: a @GET annotated method of the void return type. 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 @GET, @POST, @PUT, or @DELETE annotation from the method declaration.
A Root Resource Class does not contain resource methods. Remove @Path annotation.
Different Root Resource Classes have the same @Path annotation. Remove @Path annotation.
A @Consumes or a @Produces annotation uses a wrong MIME type. Change to */*.

Rest client tool window

Dedicated REST Client tool window supports:

  • Constituting URL addresses semiautomatically from the specified Deployment point and the @Path annotation.
  • 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
@Path annotation is updated. The contents of the Path to resource drop-down list change.
@Produces annotation is updated. The contents of the Accept drop-down list change.

See Also

Procedures:

Web Resources: