Episode 4, Create controllers

Episode 4, Create controllers #

Season 4, Spring time

Now we need to create the HTTP API

  • Hyper Text Transfer Protocol
  • Application Programming Interface

Using Intellij Idea and maven #

  1. Open the maven panel (on the to the right).
  2. You’ll see the name of your project.
  3. Now we’ll use maven to build.
  4. Navigate to Lifecycle and double-click on package.
  5. The Run panel will open at the bottom of the IDE and will show you the logs from this action.
  6. It’ll take a while till the action will finish, in the end you’ll see a message saying BUILD SUCCESS
  7. In the maven panel navigate to Plugins / spring-boot and double click on spring-boot:run
  8. This will open the Run panel, and you’ll see lots of logs, and in 2-15 seconds your app will start, depending on the machine you use.

Using command line and maven #

  1. cd into the projects root folder, where the pom.xml file is residing
  2. Type mvn clean package
  3. Press Enter
  4. Once BUILD SUCCESS
  5. Type mvn sring-boot:run
  6. Press Enter

What if build fails ? #

  1. Your build might fail because of missing or failing dependency related to jsonway / jsonpath
  2. Open pom.xml file
  3. Find this block
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
        </exclusion>
    </exclusions>
</dependency>
  1. Add this extra exclusion
<exclusion>
    <groupId>com.jayway.jsonpath</groupId>
    <artifactId>json-path</artifactId>
</exclusion>
  1. So that the complete block looks like this
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
        </exclusion>
    </exclusions>
</dependency>
  1. Rebuild the project with the package step described above.