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)
Install IntelliJ Community Edition
https://www.jetbrains.com/idea/download/?var=1§ion=mac
Spring Boot Project
Use initializer to create a new project
- Select Maven
- Add Spring Web dependency
- Select the correct Java version
Open the project in IntelliJ CE
- Trust the project
- 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!";
}
}
- Build project
- Run the project
- Open a browser and point to
localhost:8080
to verify the web application is running
Top comments (0)