Signup/Sign In

REST: Creating the Registration Application

The prerequisites for developing the registration application are:

  1. Maven configured on the machine.
  2. Eclipse (IDE) installed on the machine.
  3. Apache Tomcat Server installed in the machine.

Steps of Development

  1. Choose the directory where you want to keep the files related to this application.
  2. Open the Command Prompt → cd {your directory} → run the below mentioned command in the command prompt.
    mvn archetype:generate -DgroupId=com.rest.tutorials -DartifactId=RegistrationApp
    -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
    

    Make sure that Maven is setup before running the above command. This command will create the web application structure in your directory and pom.xml file. This pom.xml file is the metadata of your application.

    Your pom.xml will look something like this,

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.rest.tutorials</groupId>
      <artifactId>RegistrationApp</artifactId>
      <packaging>war</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>RegistrationApp Maven Webapp</name>
      <url>http://maven.apache.org</url>
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <finalName>RegistrationApp</finalName>
      </build>
    </project>

  3. Now add Jersey dependency in the pom.xml file, just like the Junit dependency is added.
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-moxy</artifactId>
        <version>2.25.1</version>
    </dependency> 
       <dependency>
       <groupId>org.glassfish.jersey.core</groupId>
       <artifactId>jersey-server</artifactId>
       <version>2.22.1</version>
    </dependency>
    <dependency>
       <groupId>org.glassfish.jersey.containers</groupId>
       <artifactId>jersey-container-servlet</artifactId>
       <version>2.22.1</version>
    </dependency>code>

  4. Run the command: mvn eclipse:eclipse

    This will generate a .classpath and a .project file so that you can import this project into the eclipse.

    Creating the Registration Application


  5. The project structure should look like this in the eclipse now.