DEV Community

NT
NT

Posted on

Setting up IntelliJ Community Edition

Install JDK

$ brew install openjdk
$ sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc
$ echo 'export CPPFLAGS="-I/opt/homebrew/opt/openjdk/include"' >> ~/.zshrc
$ source ~/.zshrc
$ java --version
openjdk 20.0.1 2023-04-18
OpenJDK Runtime Environment Homebrew (build 20.0.1)
OpenJDK 64-Bit Server VM Homebrew (build 20.0.1, mixed mode, sharing)

Enter fullscreen mode Exit fullscreen mode

Install IntelliJ Community Edition

https://www.jetbrains.com/idea/download/?var=1&section=mac

Spring Boot Project

Use initializer to create a new project

https://start.spring.io

  • Select Maven
  • Add Spring Web dependency
  • Select the correct Java version

Select the correct Java version

Open the project in IntelliJ CE

  • Trust the project
  • Specify JDK in Project Structure Specify JDK in Project Structure
  • Add a controller
package com.example.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWorldController {
    @RequestMapping("/")
    public String hello()
    {
        return "Hello Spring Boot!";
    }
}
Enter fullscreen mode Exit fullscreen mode
  • Build project
  • Run the project

Run the project

  • Open a browser and point to localhost:8080 to verify the web application is running

Hello Spring App Running

Top comments (0)