Spring Boot Hello world using Intellij Idea

Firstly you need to download and install intellij idea on your machine like below:

Intellij Idea Download Here

After installation you need to open Spring Initializr to download maven dependency like below:

Spring Initializr Download Here

Now change group id, artifact id package name according to your project and then add dependency from top right corner and add spring web dependency then click on generate like below:

After download your project you need to extract it after extracting you need to select File then select open in intellij idea like below:

After click on open you need to select your project where you extract it like below:

After loading completed your project structure look like below:

Now you can create a class inside same package and name is HelloController.java and you can write below code:

package com.deepsingh44.helloworld;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @GetMapping("/")
    public String welcome() {
        return "Hello World Example";
    }

}
  

After this right click on HelloworldApplication and run it like below:

If your server port is already in used error will come then you can go to application.properties file and change server port like below:

server.port=8883

After successfully server started you have to open any browser and type below code and hit enter so you can get result like below:

Done.

No comments: